简体   繁体   中英

Static css in Django works unstable

I have css with following content in ecommerce/ecommerce/static/css folder:

body {background: #68951c;}
h1 {color: #000000;}

When I want to change the color of the background, it changes in PyCharm, but it doesn't change on the web page even when I change the color in BOTH 1) e-commerce/static/css and 2) e-commerce/static/css manually. Even though command "python manage.py collectstatic" had run and the server had re-run it is needlessly. Only one effect - when I ctrl+X following string in html page:

  <link rel="stylesheet" type="text/css" href="{% static 'css/base.css' %}">

then the background evaporates. And when I insert the upper markup and refresh the page, it appears again

(upper markup contained in, in it is not working for some reason)

项目文件夹

I am guessing this simply is a caching problem. Try to hard reload your browser each time(or just have dev tools open)

Unless you have some more elaborate front-end build process (eg gulp, webpack etc.) In that case, you should rebuild or watch for file changes

If a lot of css files, and then you write css to a new file and you want to go back to the previous file, you have to change the file name to make it work, for example first_file.css second_file.css if you want to go back to first_file.css you have to rename first_file. css becomes first_file_rename.css like this and then it works, I don't know what the problem is, I just got the easy alternative

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM