ckeditor installing issue

Hello, I am trying to integrate CKeditor in my blog application.

models.py

from django.urls import reverse
from ckeditor.fields import RichTextField

body = RichTextField(blank= True, null = True)

settings.py

INSTALLED_APPS = [
 'ckeditor',
 'ckeditor_uploader',

]

STATIC_URL = '/static/'
STATIC_ROOT = '/home/developer/Projects/Giyu_Tomioka/blog/static'

MEDIA_URL = '/media/'
MEDIA_ROOT = '/home/developer/Projects/Giyu_Tomioka/blog/media'
CKEDITOR_UPLOAD_PATH = "uploads/"

when I migrate I get this error, I am unable to understand why.

Traceback (most recent call last):
  File "/home/developer/Projects/Giyu_Tomioka/manage.py", line 22, in <module>
    main()
  File "/home/developer/Projects/Giyu_Tomioka/manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "/home/developer/.local/lib/python3.9/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
    utility.execute()
  File "/home/developer/.local/lib/python3.9/site-packages/django/core/management/__init__.py", line 395, in execute
    django.setup()
  File "/home/developer/.local/lib/python3.9/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/home/developer/.local/lib/python3.9/site-packages/django/apps/registry.py", line 114, in populate
    app_config.import_models()
  File "/home/developer/.local/lib/python3.9/site-packages/django/apps/config.py", line 301, in import_models
    self.models_module = import_module(models_module_name)
  File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 790, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/home/developer/Projects/Giyu_Tomioka/blog/models.py", line 3, in <module>
    from ckeditor.fields import RichTextField
  File "/home/developer/.local/lib/python3.9/site-packages/ckeditor/fields.py", line 4, in <module>
    from ckeditor.widgets import CKEditorWidget
  File "/home/developer/.local/lib/python3.9/site-packages/ckeditor/widgets.py", line 3, in <module>
    from django.core.urlresolvers import reverse
ModuleNotFoundError: No module named 'django.core.urlresolvers'

It looks like you’re trying to use a seriously old and obsolete package.

The package django.core.urlresolvers was deprecated in Django 1.10 and removed in Django 2.0.

You didn’t mention which version of Django you’re using, but you should find a more modern and current method for integrating ckeditor within Django.

I am using django 3.2.
It’s only when I add CKeditor into django I get this error

I just now update to django 4.0.2 still I am getting the same issue

I think you misunderstood my response. I wasn’t commenting about the version of Django you were using, but whatever package you selected to try and integrate CKeditor into Django.

You either need to:

  • Fix the CKeditor package you are using to work with whatever version of Django you want to use.
  • Find a different CKeditor package, one that works with your version of Django
  • Integrate CKeditor directly yourself without using a third-party package.

Thank You @KenWhitesell it worked I reinstalled ckeditort. I view the package /.local/lib/python3.9/site-packages/ckeditor/widgets.py and found that it was requesting the package.

'django.core.urlresolvers'

This is my settings, maybe it can help you

from pathlib import Path
import os

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-%$w+zdq!0x@_6h0c0n-&5z69m%&17#w1%ul@(&1si*&(@klqhw'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = [
#    'blog.apps.BlogConfig', change to yours
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'ckeditor', 
    'ckeditor_uploader',
]

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

#ROOT_URLCONF = 'grace2525-site.urls' change to yours

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

#WSGI_APPLICATION = 'grace2525-site.wsgi.application'  change to yours


# Database
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': BASE_DIR / 'db.sqlite3',
    }
}


# Password validation
# https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
]


# Internationalization
# https://docs.djangoproject.com/en/3.2/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.2/howto/static-files/

STATIC_URL = '/static/'

STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')

# Default primary key field type
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

#ckeditor settings

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

MEDIA_URL = '/media/'

CKEDITOR_UPLOAD_PATH = 'ckeditor_uploads'

1 Like

Does this setting stay the same during deployment?

I think yes: it stays the same

On AWS what do be a good way to store the uploaded images? for production

That really is a different topic, potentially encountering a number of different issues. You may want to open up a new discussion topic here for that. (People seeing the “ckeditor installing issue” title might not browse further to see that the topic has actually changed.)

1 Like