Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The path for image uploads in the CKEeditor field can be altered in Django by modifying the MEDIAROOT and MEDIAURL settings in the settings.py file.

  1. Modify MEDIA_ROOT:

By default, the MEDIAROOT is set to the project's root directory. To change the MEDIAROOT to a different directory, add the absolute path of the new directory as a string to the settings.py file.

MEDIA_ROOT = '/absolute/path/to/media/'
  1. Modify MEDIA_URL:

The MEDIAURL is the base URL for serving media files. By default, it is set to '/media/'. To change the MEDIAURL, add the new URL as a string to the settings.py file.

MEDIA_URL = '/new/media/url/'
  1. Add URL pattern:

To serve media files, add a URL pattern to the project's urls.py file that maps to the MEDIA_ROOT.

from django.conf.urls import url
from django.conf import settings
from django.conf.urls.static import static

urlpatterns = [
    # other URL patterns
]

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

With these modifications, the CKEeditor field will upload images to the new specified path.