-1

When I shut down my PC and reopen my project every time I have to change the CSS file name to see the changes on the web. I have tried many ways to fix these issues.

I have researched online but I did not find any answer on this.


I have tried these ways to fix this error:

  • I have tried settings up STATIC_ROOT=''.
  • I have tried setting up STATICFILES_DIRS=[].

Please guide me to solve this error.

Adrian
  • 468
  • 2
  • 6
  • 15
Vikas_kumar
  • 7
  • 1
  • 2
  • I don't think this is a Django specific problem. It's more of a browser cache problem. try using firefox browser and force reload (ctrl+f5 or ctrl+R in chrome) – Mojtaba Jun 25 '22 at 06:02
  • checkout [this question](https://stackoverflow.com/questions/7671168/why-adding-version-number-to-css-file-path) – Mojtaba Jun 25 '22 at 06:05

1 Answers1

1

Maybe your pc is using the file stored in the cache.

You could do something like this to force update the file:

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

Here you generate a unique timestamp every time when you update the page. This triggers a update of the file..

fbzyx
  • 189
  • 1
  • 16