css - 加载后未应用Django admin css
问题描述
我正在使用 nginx 来提供我的 django 静态文件。在浏览器中我可以看到它们已经加载完毕,base.css、login.css、responsive.css 的状态都是 200,我可以点击它们并查看它们的内容。
问题是它们似乎没有应用在 html 中。html 看起来仍然完全没有应用 css 格式。nginx 日志中没有错误,chrome 中的网络选项卡中也没有错误。我试过 chrome 和 firefox
使用 Django 2.2.4
相关的nginx配置
server {
listen 8000;
server_name 127.0.0.1;
location /static/ {
autoindex on;
alias /home/ubuntu/<SECRET_PATH>/static/;
}
location / {
include proxy_params;
proxy_pass http://unix:/home/ubuntu/<SECRET_PATH>/dashboard.sock;
}
}
解决方案
根据您的评论,似乎没有为 CSS 文件返回正确的 mime 类型。在您的 NGINX conf 中,它通常位于/etc/nginx/nginx.conf
,请确保您已包含以下 mime:
include "/etc/nginx/mime.types";
在你的 mime 中,确保为 CSS 文件设置了正确的 mime 类型。
推荐阅读
- oracle - Oracle 表中的拉丁字符编码问题
- regex - 带分隔符的正则表达式子字符串
- sql-server - Windows + IIS + mssql 服务器上的 Redmine 安装
- python - 如何获取当前的 QApplication?
- php - 为我的 woocommerce 网站创建一个移动应用程序
- c# - 如何避免日期落在特定日期范围内
- php - 如何使用 where 子句获取范围之间的值
- php - 如何发送 smtp 邮件?
- xml - 如何定义 XML XSD 类型来描述“double”的子集,不包括“NaN”、“positiveInfinity”、“negativeInfinity”
- mysql - 完整表的 SQL 转储