Forums

Django, TinyMCE redactor doesn't work in admin panel

I want to add a redactor (tinymce or ckeditor) into my site admin panel. I have set all configurations (and installation) as described in documentation , but the redactor tools aren't displayed. On my local server everything works correctly. Maybe someone had the same problem too and can help me?

Is the user in this thread having the same problem?

Not quite. Because I'am using only django-tinymce without django-wysiwyg.

My code that works correctly on localhost (python 3.4, django 1.8):

in settings.py

INSTALLED_APPS = (
    ...
    'tinymce',
)

in urls.py

urlpatterns = [
    ...
    url(r'^tinymce/', include('tinymce.urls')),
]

in models.py

from django.db import models
from tinymce.models import HTMLField

class Post(models.Model):
    ...
    post_text = HTMLField(blank=False,
                          verbose_name='Пост')
   ...

result in admin panel enter image description here


But it doesn't work here. The text window get smaler, but buttom tools aren't displayed.

tinymce instaled in site-packages:

.local > lib > python3.4 > site-packages > tinymce

Can you see any errors in your browsers' javascript console?

Yes, indeed. I haven't noticed it rigth away.

enter image description here

enter image description here

So it looks like the static files for django_tinymce aren't available? Have you run collectstatic recently?

Here's our general docs on static files and django, in case they're useful

Cool, thanks, everything works now, even the ckeditor! In my settings.py I'am using STATICFILES_DIRS, but in order for collectstatic to run, there has to be STATIC_ROOT instead of STATICFILES_DIRS.

So, maybe it will be helpful for someone else:

DJANGO-TINYMCE

pip2.7 install --user django-tinymce

(Change the 2.7 appropriately if you're using a different version of Python.)

in settings.py

INSTALLED_APPS = (
    ...
    'tinymce',
)

in urls.py

urlpatterns = patterns(' ',
 ...
    (r'^tinymce/', include('tinymce.urls')),
)
# or
urlpatterns = [
    ...
    url(r'^tinymce/', include('tinymce.urls')),
]

in models.py

from django.db import models
from tinymce.models import HTMLField

class Post(models.Model):
    ...
    post_text = HTMLField()
   ...

./manage.py collectstatic

result in admin panel

see above


DJANGO-CKEDITOR

pip2.7 install --user django-ckeditor

(Change the 2.7 appropriately if you're using a different version of Python.)

in settings.py

INSTALLED_APPS = (
    ...
    'ckeditor',
)
....
STATIC_URL = '/static/'
MEDIA_URL = '/media/'
CKEDITOR_UPLOAD_PATH = "uploads/"

in urls.py

urlpatterns = patterns(' ',
 ...
    (r'^ckeditor/', include('ckeditor_uploader.urls')),
)
# or
urlpatterns = [
    ...
    url(r'^ckeditor/', include(''ckeditor_uploader.urls')),
]

in models.py

from django.db import models
from ckeditor.fields import RichTextField

class Post(models.Model):
    ...
    post_text = RichTextField()

...

./manage.py collectstatic

result in admin panel

enter image description here

if you need more tools, add in settings.py:

CKEDITOR_CONFIGS = {
    'default': {
        'toolbar': None,
    },
}

enter image description here

Awesome! Thanks for posting the detailed instructions.

Hi dear I am following this tutorial ................ Django WYSIWYG But not able to see WYSIWYG editor in admin panel.

For your above mentioned steps I have to change my content field in my model. as below (SHOWN in COMMENT)

class Post(models.Model):
    ........
    content = models.TextField()
    #content = HTMLField()

But my question is can I do this to without losing my data ?? My next question is how to makemigrations or sync db......???

Thank you guys...it helped me like a charm. thank you very much