Hello. Installed ckeditor 5.0.3. When I upload a file in the editor, it appears in the media / upload folder, but is not displayed in the editor. Just a broken image, and the path in the code is correct. I tried to put the file browser, registered in the ckeditor config:

config.extraPlugins = 'filebrowser'; config.extraPlugins = 'popup'; 

But I don’t understand whether this plugin is using the editor or not, since there are no changes before installing the plugin. In the browser console, I see the message: The article with the primary key u'add / media / upload / 2016/07/10 / qtacdg.docx 'does not exist. But along this path there is a file. setting.py:

 INSTALLED_APPS = [ ... 'ckeditor', 'ckeditor_uploader', ] STATICFILES_DIRS = ( ('static', '/root/djangoenv/bin/blago/blago/static',) ) MEDIA_ROOT = os.path.join(BASE_DIR, 'media') MEDIA_URL = 'media/' CKEDITOR_UPLOAD_PATH = 'upload/' CKEDITOR_JQUERY_URL = '//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js' CKEDITOR_CONFIGS = { 'default': { 'toolbar': 'None', }, } 

Can you help? Thank!

  • u'add / media / upload / 2016/07/10 / qtacdg.docx 'is a relative path. Somewhere cant in the settings of the base path to media - FeroxTL
  • If you put the files into a folder and open the "files on the server" through the editor, then it shows all the files that are there. Only beaten and does not open. Are the paths right? - Coveraver
  • I think you ckeditor somewhere incorrectly configured. If the media opens, then the problem is not in it - FeroxTL
  • @FeroxTL, attached setting.py. Look, please - Coveraver
  • I propose to discuss in chat chat.stackexchange.com/rooms/42303/ckeditor - FeroxTL

1 answer 1

  1. Check settings

    Firstly, the absolute path must be specified for media. That is, it must start with / and nothing else. Otherwise, the media will break into the media subdirectory of the current page, which is incorrect.

    An example of setting statics and media

     # Static files (CSS, JavaScript, Images) STATIC_URL = '/static/' MEDIA_URL = '/media/' ADMIN_MEDIA_PREFIX = '/media/admin/' STATIC_ROOT = os.path.join(BASE_DIR, 'static') MEDIA_ROOT = os.path.join(BASE_DIR, 'media') STATICFILES_DIRS = [ os.path.join(BASE_DIR, 'app1', 'static'), os.path.join(BASE_DIR, 'app2', 'filters', 'static'), ] 
  2. Check ckeditor settings

     # ckeditor CKEDITOR_UPLOAD_PATH = 'uploads/' # тут как раз может быть относительный путь 
  3. Check static and media settings

    In modern versions of django, this is done by adding the following to the main urls.py file

     urlpatterns = [ # тут ваши urls ] + static( settings.STATIC_URL, document_root=settings.STATIC_ROOT ) + static( settings.MEDIA_URL, document_root=settings.MEDIA_ROOT ) 
  • Unfortunately, due to the threshold of the rating I can not put the ball. @FeroxTL, thank you for your help - Coveraver