当我使用 runserver
运行我的项目时, django admin 显示静态文件。一切看起来都很漂亮。
但是当我使用 gunicorn
运行我的项目时Web 服务器,找不到 django 管理员的静态文件:
Not Found: /
Not Found: /favicon.ico
Not Found: /static/admin/css/base.css
Not Found: /static/admin/css/login.css
Not Found: /static/admin/css/base.css
Not Found: /static/admin/css/dashboard.css
为什么这些静态文件不是开箱即用的?
我应该采取哪些步骤来通过
gunicorn
为 django admin 提供静态文件?我在 python 3.4 中使用 Django 1.9
最佳答案
您需要通过 manage.py collectstatic
收集所有静态文件命令。文档中的更多信息 - https://docs.djangoproject.com/en/1.9/ref/contrib/staticfiles/#django-admin-collectstatic
关于Django 管理员在使用 gunicorn Web 服务器时缺少静态文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34242378/