Reputation: 173
I'm pretty new to Django. I started an app, made template and static directories, add them to the project settings and ran the server by following this tutorial. Then I wanted to change some settings in my CSS file so I modified some lines. But when I ran the python manage.py runserver
again(I ran on Windows), the changes did not take effect. The initial code of CSS is:
body {
position: relative;
padding-bottom: 10px;
min-height: 100%;
background: #f7f7f7;
}
I changed the padding resulting like this:
body {
position: relative;
padding-bottom: 50px;
min-height: 100%;
background: #f7f7f7;
}
When I ran the django server again, the new code was not taking effect. I checked the code with Chrome Dev Tools and found out the padding value was still 10px. I've been running the server again and again but with no change. Is there something I am missing with the settings?
Upvotes: 3
Views: 2985
Reputation: 594
It is browser cache problem. You can solve it in many ways but what I found as the simplest way is to try out Incognito or Private mode of your browser. You will see every single change of css file instantly.
Upvotes: 0
Reputation: 3536
I oftenly have the same issue, you should delete the staticfiles directory. Additionally, you should add "no cache" header to your HTML headers in your templates, at least for development.
<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />
In case of trouble, you can also force your browser to clear its cache.
In case you want to reconstruct the 'staticfiles' directory, you can run the command:
python manage.py collectstatic
You do not need to stop/relaunch the django server, it has no effect on the web files (HTML/JS/CSS).
Upvotes: 4
Reputation: 80
I think that you have to collect the static files with this command, from the server instance :
./manage.py collectstatic
Then the updates in static files will be considered.
Upvotes: 0