Skip to content

Instantly share code, notes, and snippets.

@pmclanahan
Created March 6, 2015 16:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pmclanahan/d8546995539df6115d7e to your computer and use it in GitHub Desktop.
Save pmclanahan/d8546995539df6115d7e to your computer and use it in GitHub Desktop.
Django Patch
diff --git a/django/contrib/staticfiles/storage.py b/django/contrib/staticfiles/storage.py
index 6a0a540..61e22f6 100644
--- a/django/contrib/staticfiles/storage.py
+++ b/django/contrib/staticfiles/storage.py
@@ -245,10 +245,13 @@ class HashedFilesMixin(object):
content = pattern.sub(converter, content)
except ValueError as exc:
yield name, None, exc
+
+ content_file = ContentFile(force_bytes(content))
+ # content likely changed, get new hashed_name
+ hashed_name = self.hashed_name(name, content_file)
if hashed_file_exists:
self.delete(hashed_name)
# then save the processed result
- content_file = ContentFile(force_bytes(content))
saved_name = self._save(hashed_name, content_file)
hashed_name = force_text(self.clean_name(saved_name))
processed = True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment