0

我在设置https://github.com/lqez/django-summernote时遇到问题。我按照配置部分的步骤进行操作,它与 django runserver 配合得很好——我在管理页面等中有summernote。但是当我将它添加到公共服务器时,它有时会加载。当我在管理页面中按 F5 时,我可以看到有时会加载 Summernote,有时却不会。在 nginx-error.log 我有这条消息,当它没有加载时:

*ip*  - - [20/Feb/2014:12:00:56 +0000] "GET /admin/django_summernote/attachment/      HTTP/1.1" 200 3347 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko)    Chrome/32.0.1700.107 Safari/537.36"

我得到类似的东西:

Not Found

The requested URL /admin/django_summernote/attachment/ was not found on this server.

当它被加载时:

    *ip* - - [20/Feb/2014:12:00:56 +0000] "GET /static/admin/css/base.css HTTP/1.1" 304 0 "http://domain.eu/admin/django_summernote/attachment/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36"
    *ip*  - - [20/Feb/2014:12:00:56 +0000] "GET /static/admin/css/changelists.css HTTP/1.1" 304 0 "http://domain.eu/admin/django_summernote/attachment/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36"
    *ip*  - - [20/Feb/2014:12:00:56 +0000] "GET /static/admin/js/admin/RelatedObjectLookups.js HTTP/1.1" 304 0 "http://domain.eu/admin/django_summernote/attachment/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36"
    *ip* - - [20/Feb/2014:12:00:56 +0000] "GET /static/admin/js/core.js HTTP/1.1" 304 0 "http://domain.eu/admin/django_summernote/attachment/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36"
*ip*  - - [20/Feb/2014:12:00:56 +0000] "GET /static/admin/js/jquery.min.js HTTP/1.1" 304 0 "http://domain.eu/admin/django_summernote/attachment/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36"
    *ip*  - - [20/Feb/2014:12:00:56 +0000] "GET /static/admin/js/jquery.init.js HTTP/1.1" 304 0 "http://domain.eu/admin/django_summernote/attachment/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36"
    *ip* - - [20/Feb/2014:12:00:56 +0000] "GET /static/admin/js/actions.min.js HTTP/1.1" 304 0 "http://domain.eu/admin/django_summernote/attachment/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36"
    *ip*  - - [20/Feb/2014:12:00:56 +0000] "GET /admin/jsi18n/ HTTP/1.1" 200 2384 "http://domain.eu/admin/django_summernote/attachment/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36"
    *ip* - - [20/Feb/2014:12:00:56 +0000] "GET /static/admin/img/icon_searchbox.png HTTP/1.1" 304 0 "http://domain.eu/admin/django_summernote/attachment/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36"

我真的很困惑,因为它安装正确并且与 django runserver 配合得很好。当它被正确加载时,它工作得很好。我的静态目录也有这些文件:

`-- django_summernote
    |-- SOURCE
    |-- django_summernote.css
    |-- jquery.fileupload.js
    |-- jquery.iframe-transport.js
    |-- jquery.ui.widget.js
    |-- lang
    |-- summernote.css
    `-- summernote.min.js

谢谢

4

1 回答 1

0

当您运行 django 项目时,它必须是调试模式runserver。如果 django 在调试模式下运行,则通过提供静态文件可以urls.py正常工作。但这在debug=False.

您必须在生产阶段通过 Web 服务器(如 nginx)提供静态文件。请参考https://docs.djangoproject.com/en/dev/howto/static-files/

于 2014-11-25T15:52:19.387 回答