django设置:
CKEDITOR_BROWSE_SHOW_DIRS = True
CKEDITOR_RESTRICT_BY_USER = True
CKEDITOR_RESTRICT_BY_DATE = False
CKEDITOR_UPLOAD_PATH = 'uploads/'
STATIC_ROOT = os.path.join(BASE_DIR, "static")
MEDIA_ROOT = os.path.join(BASE_DIR, "attachments")
STATICFILES_DIRS = (os.path.join(BASE_DIR, 'staticfiles'), )
STATIC_URL = f"{FORCE_SCRIPT_NAME}/backend/static/"
MEDIA_URL = f"{FORCE_SCRIPT_NAME}/backend/attachments/"
网址:
urlpatterns = [
path('admin/filebrowser/', site.urls),
path("grappelli/", include("grappelli.urls")),
path('admin/', admin.site.urls),
path("api/", include(api_urlpatterns)),
path('ckeditor/', include('ckeditor_uploader.urls')),
]
urlpatterns += static(settings.MEDIA_URL,
document_root=settings.MEDIA_ROOT,
show_indexes=settings.DEBUG)
urlpatterns += static(settings.STATIC_URL,
document_root=settings.STATIC_ROOT,
show_indexes=settings.DEBUG)
if settings.DEBUG:
import debug_toolbar
urlpatterns = [
path("__debug__/", include(debug_toolbar.urls)),
] + urlpatterns
nginx:
location /project_name/ {
set $service project_name;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://$service;
client_max_body_size 16m;
}
在dev中,all工作、上传和浏览,但在prod中不存在(AH00128: File不存在:/var/www/html/project_name/ckeditor/上载)。我尝试将别名/根添加到nginx,将ckeditor路径更改为re_path(r'^ckeditor/',include('ckeditor_uploader.urls')),但仍然什么也没有(不仅上传,浏览也不工作。
例如,文件浏览工作,但不使用ckeditor。我不知道为什么。
发布于 2022-04-04 05:58:48
在service.conf -> WSGIScriptAliasMatch ckeditor别名中添加项目apache设置:
WSGIScriptAliasMatch ^/${SERVICE}/((admin|api|grappelli|ckeditor)/.*)$ /${SERVICE}/backend/${PROJECT}/wsgi.py/$1
现在起作用了。
https://stackoverflow.com/questions/71723492
复制相似问题