Не удается загрузить изображение с помощью Django-CKEditor (ошибка 400)
когда я хочу загрузить изображение в CKEditor, он выдает ошибку "HTTP error occurred during file upload (error status: 400)."
посмотрите изображение ниже
внутри urls.py
from django.contrib import admin
from django.urls import path,include
from django.conf import settings
from django.conf.urls import url
from django.conf.urls.i18n import i18n_patterns
from django.conf.urls.static import static
urlpatterns = i18n_patterns(
url(r'^admin/clearcache/', include('clearcache.urls')),
path('admin/', admin.site.urls),
path('', include('frontpages.urls')),
path('ckeditor/',include('ckeditor_uploader.urls')),
path('i18n/', include('django.conf.urls.i18n')),
prefix_default_language=False,
)
handler404='frontpages.views.error_404_view'
if settings.DEBUG:
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
внутри settings.py ---> для CKEDITOR
#Ckeditor
CKEDITOR_IMAGE_BACKEND = "pillow"
CKEDITOR_UPLOAD_PATH="uploads/"
CKEDITOR_CONFIGS={
'myconfig':{
'toolbar':"Custom",
'toolbar_Custom':[
['Styles','Format','Font','FontSize','BidiLtr','BidiRtl'],
['JustifyLeft','JustifyCenter','JustifyRight','NumberedList', 'BulletedList','Bold','Italic','Underline','Strike','Undo','Redo'],
['Link','Unlink','Anchor'],
['TextColor','BGColor'],
['Smilely','SpecialChar'],
['Source','Scayt','Maximize'],
['Table','Templates','Iframe'],
],
'height': 100,
},
}
не могли бы вы помочь мне с этим
чтобы иметь возможность загружать изображения, попробуйте следующее
pip install django-ckeditor // or just make sure it is installed
в настройках:
INSTALLED_APPS = [
...
'ckeditor',
'ckeditor_uploader',
],
// at the bottom of the file add
CKEDITOR_UPLOAD_PATH = "uploads/"
CKEDITOR_IMAGE_BACKEND = "pillow"
в основных урлах:
path('ckeditor/', include('ckeditor_uploader.urls')),
в вашем models.py
from ckeditor_uploader.fields import RichTextUploadingField
body = RichTextUploadingField(blank=True, null=True) // body, image, or whatever name you choose.
это должно сработать.