【问题标题】:Django admin missing static files when using gunicorn web server使用 gunicorn Web 服务器时 Django 管理员缺少静态文件
【发布时间】:2016-03-18 11:28:56
【问题描述】:

当我使用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 管理员提供静态文件?

我正在使用 Django 1.9 和 python 3.4

【问题讨论】:

  • 不要被反对票或傲慢的 cmets 吓倒。这不是一个愚蠢的问题。

标签: django


【解决方案1】:

您需要通过manage.py collectstatic 命令收集所有静态文件。文档中的更多信息 - https://docs.djangoproject.com/en/1.9/ref/contrib/staticfiles/#django-admin-collectstatic

【讨论】:

  • 我收到Refused to apply style from 'http://0.0.0.0:8000/static/admin/css/base.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled 错误怎么办?
猜你喜欢
  • 2011-01-21
  • 1970-01-01
  • 2015-07-08
  • 2014-07-06
  • 1970-01-01
  • 2011-06-23
  • 2020-10-25
  • 2013-12-08
  • 1970-01-01
相关资源
最近更新 更多