CKedit 图片上传不起作用

问题描述 投票:0回答:2

这是我的

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'

错误代码

我将使用 CKeditor 上传图像。 不过,有一个

404 error
。 我该怎么办?

python django ckeditor
2个回答
3
投票

要使用开发服务器传递媒体文件,您需要在 urls.py 中添加类似的内容

urlpatterns = [
    # ... the rest of your URLconf goes here ...
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

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


0
投票

我有同样的问题(不完全相同),你必须保存你的图像(静态)并将地址传递给CKeditor。

© www.soinside.com 2019 - 2024. All rights reserved.