Search code examples
djangodjango-modelsckeditor

Django can't load ckeditor in the admin page


This is my settings.py file

INSTALLED_APPS = [
    'search.apps.SearchConfig',
    'user.apps.UserConfig',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.humanize',
    'django_node_assets',
    'ckeditor',
    'ckeditor_uploader',
]

CKEDITOR_BASEPATH = "./search/static/ckeditor/ckeditor/"
CKEDITOR_UPLOAD_PATH = "/media/"

This is the models.py file

from ckeditor.fields import RichTextField
from ckeditor_uploader.fields import RichTextUploadingField

class Content(models.Model):
    heading = models.ForeignKey(SubTopics, on_delete=models.CASCADE)
    content = RichTextField()

    def __str__(self):
        return self.heading.heading

This rich text editor is not showing on the admin page. Even no text field is shown on the page, just blank space.

I got the solution. remove CKEDITOR_BASEPATH and it will work


Solution

  • you need to collect the static files. Use the command below in the terminal

    python manage.py collectstatic