Home:ALL Converter>django ckeditor image upload

django ckeditor image upload

Ask Time:2019-02-22T19:52:39         Author:dongmin kim

Json Formatter

I'm using Django-ckeditor in my website.

I'm especially using

RichTextUploadingField()

in my model. and other option just works fine, except image upload.

1. Error Message

I'm getting an error message of

"Incorrect Server Response" and especially, chrome devtools indicates that


ckeditor.js:21 [CKEDITOR] Error code: filetools-response-error.

ckeditor.js:21 [CKEDITOR] For more information about this error go to https://docs.ckeditor.com/ckeditor4/docs/#!/guide/dev_errors-section-filetools-response-error


2. Guess

I have tried uploading images using ckeditor in my admin page,

authorized as superuser in django, it works.

However, logged in as the normal user account, I've tried the same thing, but it does not work.

So my guess is it has some kind of authorization problem. But I can't figure out where to start debugging in my django-ckeditor.

What things should I be checking? Thanks in advance.

Author:dongmin kim,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/54826503/django-ckeditor-image-upload
Kristiyan Gospodinov :

This is happening because the default urls are decorated with @staff_member_required(https://github.com/django-ckeditor/django-ckeditor/blob/master/ckeditor_uploader/urls.py). To avoid this, instead of including the urls like so url(r'^ckeditor/', include('ckeditor_uploader.urls')) you could define them one by one in your urls.py with the login_required decorator:\nfrom django.conf.urls import url\nfrom django.contrib.auth.decorators import login_required\n\nfrom ckeditor_uploader import views\n\nurlpatterns = [\n .....your other urls\n url(r'^ckeditor/upload/', login_required(views.upload), name='ckeditor_upload'),\n url(r'^ckeditor/browse/', never_cache(login_required(views.browse)), name='ckeditor_browse'),\n]\n\nLike this you are limiting the uploads to all users that are logged in.",
2019-02-23T18:29:43
Harman Kibue :

Add following imports in the project urls.py:\nfrom django.contrib.auth.decorators import login_required\nfrom django.views.decorators.cache import never_cache\nfrom ckeditor_uploader import views as ckeditor_views\n\nReplace the following row in the urls.py:\npath('ckeditor/', include('ckeditor_uploader.urls')),\n\nwith\npath('ckeditor/upload/', login_required(ckeditor_views.upload), name='ckeditor_upload'),\npath('ckeditor/browse/', never_cache(login_required(ckeditor_views.browse)), name='ckeditor_browse'),\n",
2021-05-03T17:27:34
yy