gunicorn + mezzanine:找不到静态文件

问题描述 投票:1回答:1

我默认安装了Mezzanine CMS,我会尝试用gunicorn服务

- 使用python manage.py runserver,所有静态文件仅在DEBUG = True时提供

日志说:

... (DEBUG=False)
[07/Sep/2018 12:23:56] "GET /static/css/bootstrap.css HTTP/1.1" 301 0
[07/Sep/2018 12:23:57] "GET /static/css/bootstrap.css/ HTTP/1.1" 404 6165
...

- 使用gunicorn helloworld.wsgi --bind 127.0.0.1:8000,没有发现静电!

日志说:

$ gunicorn helloworld.wsgi --bind 127.0.0.1:8000

[2018-09-07 14:03:56 +0200] [15999] [INFO] Starting gunicorn 19.9.0
[2018-09-07 14:03:56 +0200] [15999] [INFO] Listening at: http://127.0.0.1:8000 (15999)
[2018-09-07 14:03:56 +0200] [15999] [INFO] Using worker: sync
[2018-09-07 14:03:56 +0200] [16017] [INFO] Booting worker with pid: 16017
Not Found: /static/css/bootstrap.css/
Not Found: /static/css/mezzanine.css/
Not Found: /static/css/bootstrap-theme.css/
Not Found: /static/mezzanine/js/jquery-1.8.3.min.js/
Not Found: /static/js/bootstrap.js/
Not Found: /static/js/bootstrap-extras.js/

请看一下url想要的:gunicorn或夹层(或者?)在url的末尾添加一个/字符。

我做了这个命令太python manage.py collectstatic没有效果:(

STATIC_ROOT是正确的,我申请了https://docs.djangoproject.com/en/1.10/howto/static-files/#serving-static-files-during-development

你有提示或解决方案吗?我怕我没有正确搜索!

谢谢Momo

django python-3.x gunicorn django-staticfiles mezzanine
1个回答
0
投票

对我来说没关系,谢谢!

正确的搜索找到了答案

- 对于内部服务器DEBUG=False不会提供静态文件,它是webserver(nginx,apache)的工作:Why does DEBUG=False setting make my django Static Files Access fail?

如果您仍然需要在本地服务器静态(例如,无需调试进行测试),您可以在不安全模式下运行devserver:manage.py runserver --insecure

- 对于gunicorn web服务器,我们需要在qazxsw poi手动添加静态:qazxsw poi

urls.py,添加:

How to make Django serve static files with Gunicorn?

更多信息urls.py

做得好!

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