[Django]-Django CSS not updating

108๐Ÿ‘

โœ…

You can bypass the cache using ctrl + F5

for detailed reference: https://en.wikipedia.org/wiki/Wikipedia:Bypass_your_cache

18๐Ÿ‘

You have to click on Ctrl + f5 every time to update your CSS, which isnโ€™t dope.
You can actually do something like this:

<link rel="stylesheet" href="/static/css/mycss.css?{% now "U" %}"/>

The {% now โ€œUโ€ %} will generate a random timestamp which updates your CSS every time you reload the page. I hope this works.

For better understanding check out: click here

๐Ÿ‘คXamuel San

6๐Ÿ‘

If you are on mac and using safari, you can press shift then press the reload key.

๐Ÿ‘คVanice Leung

2๐Ÿ‘

ctrl+f5 for Chrome and Windows helped.

2๐Ÿ‘

Bypass your cache โ€” Simple instructions

In most Windows and Linux browsers:

Hold down Ctrl and press F5.

In Apple Safari:

Hold down โ‡ง Shift and click the Reload toolbar button.
In Chrome and Firefox for Mac:

Hold down both โŒ˜ Cmd+โ‡ง Shift and press R.

know more

๐Ÿ‘คMD SHAYON

2๐Ÿ‘

It happens during development (when DEBUG is set to True in settings.py) if you change the static files under the directory set STATIC_ROOT, instead of the static directories under the particular app.

In other words, when working locally (on localhost) and DEBUG is set to True, do not forget to change the static files served under your app directory.

๐Ÿ‘คLuke

1๐Ÿ‘

In addition to the answer of Xamuel San, if you are using Jinja to link your stylesheet, then you can try the following:

<link rel="stylesheet" type="text/css" href='{% static '/css/main.css' %}?{% now "U" %}'>

It perfectly worked on Chrome and Firefox. You can also use crtl+f5 to do the same but manually.

1๐Ÿ‘

In chrome you can press Ctrl + F5. If this does not work restart apache

๐Ÿ‘คDarwin

0๐Ÿ‘

i prefer to temporarily disable the browser cache.

right click => inspect => network

[]Disable cache

๐Ÿ‘คJonatan Garbuyo

0๐Ÿ‘

You can try this:

specify type attribute in the link tag/field.

<link rel="stylesheet" type="text/css" href="{% static '/css/Style.css' %}"/>
๐Ÿ‘คuser14806542

0๐Ÿ‘

Most browsers allow you to disable http caching to some degree. In Mozilla, if youโ€™re using the Web Developer tools, thereโ€™s a setting to do this.

Mozilla Web Dev Tool Settings

๐Ÿ‘คAustin A

Leave a comment