I am making a Web app using Django and was having some trouble getting the changes made in the CSS file (which is stored in the static directory of my app) to reflect onto the development server.
To be clear the server is able to access static files, however, it is currently stuck on an old iteration of my CSS file. A similar problem had occurred a few weeks ago, when any change I made to the CSS file wasn't showing up. That problem fixed itself after a few days.
However, not getting immediate visual feedback is extremely frustrating. I have tried all of the following to rectify the problem:
My static resources are kept in the 'static' directory of one of my apps -- 'post_it_gen' which is part of the project. According to the documentation this should be automatically searched by Django.
Any new suggestions would be greatly appreciated.
Browser Cache If you are adding/modifying in-line CSS or JavaScript and not seeing the changes reflected in the HTML source, the page is likely being cached. The solution may be to purge the WordPress object cache, which stores our page caching (Batcache) renders.
Django will use the first static file it finds whose name matches, and if you had a static file with the same name in a different application, Django would be unable to distinguish between them. We need to be able to point Django at the right one, and the best way to ensure this is by namespacing them.
If you develop locally using Django's server there's no need to use the collectstatic
command, it is only meant to collect all static dependencies to a single access point where you can point your 'real' server to, e.g. apache, lighttpd, nginx etc.
As for your problem, you insinuate it 'magically' fixes it self after a few days. Have you tried resetting your browser's cache?
In my case, my browser was caching the Js and CSS files and thus I was unable to see the changes.
You can try hard refreshing the page
For chrome/chromium browsers:
Ctrl + F5 or Ctrl + Shift + R
both works for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With