静态文件更改未反映在投放的样式表中 [英] Static file changes not reflected in served stylesheet

查看:52
本文介绍了静态文件更改未反映在投放的样式表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试更改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.

  1. 您的浏览器正在缓存样式表.要禁用此缓存,您可以打开开发人员工具,进入网络"标签,然后点击禁用缓存".(在 Firefox 将所有CSS 收集到一个文件中,然后即可提供该文件.
  1. 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).
  2. 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆