-
Notifications
You must be signed in to change notification settings - Fork 282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to collectstatic with non-default STATICFILES_STORAGE #149
Unable to collectstatic with non-default STATICFILES_STORAGE #149
Conversation
I've also been having this issue, haven't found a good fix yet. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's a good practice to have laziness for this kind of things.
static("a") | ||
self.fail("static must raise an exception") | ||
except ValueError: | ||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
something like self.assertRaises
instead ?
_normalize_plugins_config() | ||
finally: | ||
staticfiles_storage._setup() | ||
_normalize_plugins_config() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe add some comments to explain what's expected behaviour we should have here
@leplatrem Done. I agree that this should be lazy. Unfortunately I failed (in the March) to fix this quickly, but I don't quite remember why. |
Thanks! A test is failing...
|
Yes, it is intended to fail. It mimics This PR shouldn't be merged as-is. It should be extended with a fix. I may have some time for this in the near future, but if someone else wants to take this one - you're welcome! |
Fix for non-default STATICFILES_STORAGE (supersedes #149)
When STATICFILES_STORAGE is set to some complicated storage (like
django.contrib.staticfiles.storage.ManifestStaticFilesStorage
) and DEBUG is set to off,static
templatetag might raise a ValueError complaining about non-existing file (see the attached traceback).As a result, it is impossible for collectstatic to actually create these non-existing files, unless it is run with DEBUG=True for the first time.
This is caused by filling
PLUGINS
during app import.The clear solution (as for me) is to replace PLUGINS dict with a class which lazily calls
static
when required. I might work on it, if you think this would be an appropriate solution.Added a failing testcase for this.
Here is a traceback of collectstatic call (django 1.9):