79666091

Date: 2025-06-14 19:17:35
Score: 1
Natty:
Report link

I had that same issue, where it was loading some CSS I had entered a day ago, but not new CSS. I have not tried Gmuliu Gmuni's suggestion to run django-admin collectstatic (as defined by docs). Instead, I did a hard reload in Firefox to get rid of cache, and it worked fine.

The Django documentation states that,

ManifestStaticFilesStorage

class storage.ManifestStaticFilesStorage

A subclass of the StaticFilesStorage storage backend which stores the file names it handles by appending the MD5 hash of the file’s content to the filename. For example, the file css/styles.css would also be saved as css/styles.55e7cbb9ba48.css.

The purpose of this storage is to keep serving the old files in case some pages still refer to those files, e.g. because they are cached by you or a 3rd party proxy server. Additionally, it’s very helpful if you want to apply far future Expires headers to the deployed files to speed up the load time for subsequent page visits.

The storage backend automatically replaces the paths found in the saved files matching other saved files with the path of the cached copy (using the post_process() method). The regular expressions used to find those paths (django.contrib.staticfiles.storage.HashedFilesMixin.patterns) cover:

  • The @import rule and url() statement of Cascading Style Sheets.

  • Source map comments in CSS and JavaScript files.

According to that same link (further up the page):

On subsequent collectstatic runs (if STATIC_ROOT isn’t empty), files are copied only if they have a modified timestamp greater than the timestamp of the file in STATIC_ROOT. Therefore if you remove an application from INSTALLED_APPS, it’s a good idea to use the collectstatic --clear option in order to remove stale static files.

So, django-admin collectstatic only works with an updated directory (if I'm reading this right), and my VSCode addition to the CSS file didn't update the directory timestamp when it did so for the file.

I'm new to Django, myself, so please correct me if I'm wrong.

Reasons:
  • Whitelisted phrase (-1): it worked
  • RegEx Blacklisted phrase (1.5): I'm new
  • Long answer (-1):
  • Has code block (-0.5):
  • User mentioned (1): @import
  • Low reputation (1):
Posted by: Josh Borthick