In most of the site I use a self-written WYSIWYG editor, so it's not as advanced as I'd like. But for writing articles on the site, CKEditor is used, a very powerful and good editor. Nuance is that writing articles is available for all registered users of the site. But by default CKEditor allows you to upload images only to users with the status of staff.
For all other users, either an error page or the main page of the site will open instead of a file manager to search for images or the downloaded image.
A little polished the documentation, I managed to fix this problem. And to be honest, the solution looks rather strange, although it is proposed in the official documentation for the editor.
The bottom line is that usually for the image loading module, the urls are connected as follows.
urlpatterns = [ url(r'^ckeditor/', include('ckeditor_uploader.urls')), ]
And if you look in the sources ckeditor , you can see the following
urlpatterns = patterns( '', url(r'^upload/', staff_member_required(views.upload), name='ckeditor_upload'), url(r'^browse/', never_cache(staff_member_required(views.browse)), name='ckeditor_browse'), )
So the function staff_member_required as you already understood, restricts users' access to this functionality. That is, only the staff can upload images and search for images through the file browser on the site.
And what does the official documentation offer us instead of some setting flag?
Correctly, write directly the paths to the views, that is, in this way.
urlpatterns = [ url(r'^upload/', login_required(upload), name='ckeditor_upload'), url(r'^browse/', login_required(never_cache(browse)), name='ckeditor_browse'), ]
That is, we throw out staff_member_required and replace it with login_required to give access to all users of the site, except unauthorized.
In my opinion, a rather strange decision, when it could be done with a variable in the settings. This is slightly inconvenient and illogical.
For Django I recommend VDS-server of Timeweb hoster .
Ай малаца! Спасибо))
Здравстсвуйте Евгений, непонятно мне где эти исходники найти?
Добрый день.
На GitHub исходники, можете посмотреть в официальном репозитории
Спасибо!!!