我想在本地主机上的 Gunicorn 下运行我的 django 项目。我安装并集成了gunicorn。当我跑步时:
python manage.py run_gunicorn
它可以工作,但没有任何静态文件(css 和 js)
我在 settings.py 中禁用了 debug 和 template_debug (使它们为 false),但它仍然是相同的。我错过了什么吗?
我称静态为:
{{ STATIC_URL }}css/etc....
When in 发展模式和时间您正在使用其他服务器进行本地开发将其添加到您的urls.py
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
# ... the rest of your URLconf goes here ...
urlpatterns += staticfiles_urlpatterns()
注意staticfiles_urlpatterns()
仅当DEBUG = True
设置在你的settings.py
.
更多信息here https://docs.djangoproject.com/en/1.4/howto/static-files/#serving-static-files-in-development
When in 生产你从来没有把gunicorn放在前面。相反,你使用
像 nginx 这样的服务器,它将请求分派给 Gunicorn 工作池并提供静态文件。
See here http://gunicorn.org/deploy.html
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)