Django ckeditor上传不在生产中

发布于 2025-01-18 11:44:24 字数 2438 浏览 2 评论 0 原文

“”

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/"

urls:

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 ash all Works,上传和浏览中,但在不存在的产品中,file不存在:/var/var/www/www/www/html/project_name/ckeditor/upload) 。我尝试将别名/root添加到nginx config,将ckeditor路径更改为re_path(r'^ckeditor/',inclage('ckeditor_uploader.urls'')),仍然什么都没有(不仅上传,浏览,浏览不起作用,

例如filebrowse works workes works works works workes works works ask不是Ckeditor。

django settings:

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/"

urls:

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;
  }

In dev all works, upload and browse, but in prod with not (AH00128: File does not exist: /var/www/html/project_name/ckeditor/upload). I try add alias/root to nginx config, change ckeditor path to re_path(r'^ckeditor/', include('ckeditor_uploader.urls')) and still nothing( Not only upload, browse too not working

For example filebrowse works, but not ckeditor. I dont know a reason why.
enter image description here
enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

零度° 2025-01-25 11:44:24

添加service.conf - >的项目apache设置wsgiscriptaliasmatch ckeditor别名:

WSGIScriptAliasMatch ^/${SERVICE}/((admin|api|grappelli|ckeditor)/.*)$ /${SERVICE}/backend/${PROJECT}/wsgi.py/$1

现在起作用。

Add in projects apache settings in service.conf -> WSGIScriptAliasMatch ckeditor alias:

WSGIScriptAliasMatch ^/${SERVICE}/((admin|api|grappelli|ckeditor)/.*)$ /${SERVICE}/backend/${PROJECT}/wsgi.py/$1

Now works.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文