1

I am using Django with Bootstrap 4 in project with my own custom css for design.

Every time when I make new design change in css file I have to clear my browser cache and reload the page to view changes or if I rename the custom css file then my design changes are visible.

Is there any way I can disable caching just for development and I can enable while it is in live environment. I am new to this and Django is huge. Please share what is best practice to do this.

darth vader
  • 501
  • 8
  • 11
  • Can you read the document about [Django’s cache framework](https://docs.djangoproject.com/en/3.1/topics/cache/)? – Rayees AC Sep 17 '20 at 16:13

1 Answers1

2

Append ?n={{random_number}} in your template to the css path.

You can write a custom template tag to get a random number like this

maremare
  • 414
  • 1
  • 4
  • 19
  • How will this solve the problem. I didn't get the point. – darth vader Sep 18 '20 at 16:29
  • 2
    It will force browser to get the file from server (because it is a new path with a new get param). You can read more here: https://stackoverflow.com/a/9692722/2732913 – maremare Sep 18 '20 at 16:34