静态文件更改未反映在投放的样式表中

编程入门 行业动态 更新时间:2024-10-09 04:23:37
本文介绍了静态文件更改未反映在投放的样式表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

  • 您的浏览器正在缓存样式表.要禁用此缓存,您可以打开开发人员工具,进入网络"标签,然后点击禁用缓存".(在 Firefox 或 Chrome ,至少).
  • 您的项目已配置为提供收集的文件.要解决此问题,请运行 ./manage.py collectstatic -这将将所有CSS 收集到一个文件中,然后即可提供该文件.
  • 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.
  • 更多推荐

    静态文件更改未反映在投放的样式表中

    本文发布于:2023-11-01 11:06:09,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1549168.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:静态   样式表   文件

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!