CKedit图片上传不起作用

时间:2017-01-06 04:23:38

标签: python django ckeditor

这是我的urls.py

from django.conf.urls import include, url
from django.contrib import admin
from django.contrib.auth import views
from django.conf import settings

urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
url(r'^accounts/login/$', views.login, name='login'),
url(r'^accounts/logout/$', views.logout, name='logout', kwargs={'next_page':     '/'}),
url(r'^ckeditor/', include('ckeditor_uploader.urls')),
url(r'', include('blog.urls')),
]

settings.py

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
LOGIN_REDIRECT_URL = '/'
MEDIA_URL = '/media/'
CKEDITOR_UPLOAD_PATH = 'uploads/'
CKEDITOR_JQUERY_URL = 'http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js'

错误代码

enter image description here

我将使用CKeditor上传图片。 但是,有一个404 error。 我该怎么办?

1 个答案:

答案 0 :(得分:3)

要使用开发服务器提供媒体文件,您需要在urls.py

中使用这样的内容
urlpatterns = [
    # ... the rest of your URLconf goes here ...
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

据我所知,Ckeditor不会自动添加,因此您需要将此代码添加到您的urls.py