Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 17389

Django and TinyMCE: NameError: name 'url' is not defined

$
0
0

I am trying to get TinyMCE working in Django. Here is what I did:

  • Using this package as a reference: django-tinymce4-lite
  • Successfully ran pip install django-tinymce4-lite; package installs fine
  • Added tinymce to INSTALLED_APPS in settings.py

Then here it gets tricky:

Add tinymce.urls to urls.py for your project:urlpatterns = [    ...    url(r'^tinymce/', include('tinymce.urls')),    ...]

When I do this, I get this error:

url(r'^tinymce/', include('tinymce.urls')),  NameError: name 'url' is not defined

I have tried the following:

  • Restarting django
  • Instead of placing this in my project's urls.py I have tried my app's urls.py
  • I have tried to convert this to "path('tinymce/', include('tinymce.urls'))," because all other entries use 'path' and not 'url', but that didn't work either (ModuleNotFoundError: No module named 'tinymce.urls)
  • I have tried another tinymce plugin

None of this helped. Any suggestions?

UPDATE

As per the suggestions, I updated url to path. Now I have a new error:

ModuleNotFoundError: No module named 'tinymce.urls'

Here is my urls.py:

from django.urls import include, pathfrom django.contrib import adminfrom django.conf import settingsfrom django.conf.urls.static import staticurlpatterns = [    path('', include('core.urls')),    path('tinymce/', include('tinymce.urls')),]if settings.DEBUG:    urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

This error made me doubt if I had installed the plugin correctly. But it seems I have:

pip install django-tinymce4-liteRequirement already satisfied: django-tinymce4-lite in /usr/local/lib/python3.6/site-packagesRequirement already satisfied: Django>=1.8.0 in /usr/local/lib/python3.6/site-packages (from django-tinymce4-lite)Requirement already satisfied: jsmin in /usr/local/lib/python3.6/site-packages (from django-tinymce4-lite)Requirement already satisfied: pytz in /usr/local/lib/python3.6/site-packages (from Django>=1.8.0->django-tinymce4-lite)

Viewing all articles
Browse latest Browse all 17389

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>