静态文件更改未反映在投放的样式表中 [英] Static file changes not reflected in served stylesheet
问题描述
当我尝试更改CSS文件中的任何内容时,在浏览器显示的样式表中看不到任何更改.
When I'm trying to change anything in my CSS files, I can't see any changes in the stylsheet shown to the browser.
构建项目后,更改样式(例如, default.css
中的背景颜色从白色更改为黑色).然后,我运行该项目,但页面背景仍然是白色.我认为它来自HTML模板文件中的 {%load static%}
,但我不太确定.我发现在CSS中应用更改的唯一方法是创建一个新的CSS文件并从HTML模板引用它.有任何解决方法的想法吗?
After I build the project, I change a style (for example, the background color in default.css
from white to black). I then run the project, but the page background still will be white. I think it comes from {% load static %}
in my HTML template file, but I'm not quite sure. The only way I found to apply changes in CSS is to create new a CSS file and reference it from the HTML template. Any ideas how to fix it?
推荐答案
这里有几件事可能会给您带来麻烦.
There are a couple things here that could be giving you issues.
- Your browser is caching the stylesheets. To disable this caching, you can open your developer tools, go the network tab, and click "Disable cache" (in Firefox or Chrome, at least).
- Your project is configured to serve the collected files. To fix this, run
./manage.py collectstatic
- this will collect all your CSS into a single file, which can then be served.
这篇关于静态文件更改未反映在投放的样式表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!