Reactoo
Reactoo

Reputation: 1032

Ckeditor texteditor not appearing in django admin where RichTextfield is applied

I have tried everything but the texteditor is not appearing in the admin page in the richtextfield type. I installed django ckeditor and have the following in the settings.py:

Richtextfield pic

CKEDITOR_BASEPATH = "/static/ckeditor/ckeditor/"
CKEDITOR_UPLOAD_PATH = "uploads/"
#ckeditor configs #todo
CKEDITOR_CONFIGS = {
'default': {
'toolbar': 'full',
'width': 1000,
'height': 400
},
}

DEBUG = False

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static/')

MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media/')

My urls is as follows:

urlpatterns = [
path('admin/', admin.site.urls),
path('', admin.site.urls),
path('', include('apps.accounts.urls')),
path('', include('apps.blogs.urls')),
path('', include('apps.enquiry.urls')),
path('', include('apps.packages.urls')),
path('', include('apps.booking.urls')),
path('ckeditor', include('ckeditor_uploader.urls')),
]+static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
# ]+static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

if settings.DEBUG is True:
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

I have even tried collectstatic and every files are collected but still the richtextfield appears blank. How to solve this??

Upvotes: 0

Views: 814

Answers (1)

snag9677
snag9677

Reputation: 63

Perhaps a bit late but might help future readers.

The problem - Django ckeditor was not loading any widgets, including on the admin page.

Solution - I upgraded the package to the latest version and ran collectstatic

My CKEditor settings

INSTALLED_APPS = [
    # CUSTOM APPS
    'users', # For users mechanism - login, profile, registration etc
    'API',

    # Django PIP Apps
    'django_extensions', # Django Extensions
    'ckeditor', # django-ckeditor (RichTextEditor)
    'ckeditor_uploader',
    'django_archive', # django-archive

    
    # DJANGO APPS
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',

    # Non Default Django Apps
    'django.contrib.admindocs',
]



CKEDITOR_UPLOAD_PATH  = "ckeditor_media"
CKEDITOR_CONFIGS = {
    'default': {
        'toolbar': 'full',
        'height': 300,
        'width': 960,
        'skin': 'moono-lisa',
        'uiColor': '#b7d6ec',
    },
}

CKEDITOR_RESTRICT_BY_USER = False
CKEDITOR_UPLOAD_SLUGIFY_FILENAME = False
CKEDITOR_IMAGE_BACKEND = None
CKEDITOR_ALLOW_NONIMAGE_FILES = True

Upvotes: 0

Related Questions