#19295 closed Cleanup/optimization (fixed)
Document that runserver --insecure doesn't work with DEBUG False and CachedStaticFilesStorage
Reported by: | Apreche | Owned by: | Keith Edmiston |
---|---|---|---|
Component: | Documentation | Version: | 1.4 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
How to reproduce:
Enable the CachedStaticFilesStorage in your settings and turn DEBUG off.
DEBUG = False STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.CachedStaticFilesStorage'
Turn on the runserver with the insecure flag
$ python manage.py runserver --insecure
Visit your runserver in your browser, and the static files will not load. When using the default django.contrib.staticfiles.storage.StaticFilesStorage the static files will load.
The reason is because of this section in contrib/staticfiles.storage.py
100 def url(self, name, force=false): 101 """ 102 Returns the real URL in DEBUG mode. 103 """ 104 if settings.DEBUG and not force: 105 hashed_name, fragment = name, '' 106 else:
When DEBUG is False, the automatic static file serving in runserver is disabled. But using runserver with --insecure will re-enable it. Because the CachedStaticFilesStorage only looks at the DEBUG flag, it will not work properly in this scenario. Perhaps that force parameter could be set to True when the --insecure flag is passed to runserver?
Yes, this is an extremely rare and low-priority edge case, but still a bug.
It's also not clear what the expected behavior is when both the --nostatic and --insecure flags are passed to runserver simultaneously. They sort of cancel each other out. Personally I feel the nostatic should take priority.
Change History (9)
comment:1 by , 12 years ago
Triage Stage: | Unreviewed → Design decision needed |
---|
comment:2 by , 12 years ago
Triage Stage: | Design decision needed → Accepted |
---|---|
Type: | Bug → Cleanup/optimization |
I'm pretty sure you're way out of scope for both runserver and the CachedStaticFilesStorage. So to answer your question, to fix this "bug" stop using --insecure in the first place.
I'm accepting this ticket to warn users in the docs that both modes are incompatible.
comment:3 by , 11 years ago
Component: | contrib.staticfiles → Documentation |
---|---|
Easy pickings: | set |
Summary: | runserver --insecure doesn't work with DEBUG False and CachedStaticFilesStorage → Document that runserver --insecure doesn't work with DEBUG False and CachedStaticFilesStorage |
comment:4 by , 11 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:5 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
I can reproduce the issue, but I don't know how to fix it.