I am trying to get TinyMCE working in Django. Here is what I did:
pip install django-tinymce4-lite
; package installs fineThen 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:
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, path
from django.contrib import admin
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
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-lite
Requirement already satisfied: django-tinymce4-lite in /usr/local/lib/python3.6/site-packages
Requirement 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)
Since you are using django 2.0 you should use path
instead of url
:
from django.urls import path
urlpatterns = [
...
path('tinymce/', include('tinymce.urls')),
...
]
You can find more details here.