#14582 closed (fixed)
django.contrib.staticfiles development file serving is backward-incompatible if MEDIA_URL was pointing to /static/ folder
Reported by: | Mikhail Korobov | Owned by: | Jannis Leidel |
---|---|---|---|
Component: | Contrib apps | Version: | dev |
Severity: | Keywords: | staticfiles | |
Cc: | tkaemming | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
My project has these settings:
# settings.py MEDIA_ROOT = os.path.join(PROJECT_PATH, 'static') MEDIA_URL = '/static/'
#urls.py if settings.DEBUG: urlpatterns += patterns('', (r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}), )
after updating from django 1.2 to django trunk @14352 static files serving during development becomes broken: all requests to static files return 404 error now.
Attachments (1)
Change History (6)
comment:1 by , 14 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 14 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
by , 14 years ago
Attachment: | ticket-14582.diff added |
---|
Adds --nostatic option to "runserver" management command.
comment:3 by , 14 years ago
Cc: | added |
---|---|
Has patch: | set |
I've created a patch for this that adds a "--nostatic" option to the "runserver" management command which prevents the StaticFilesHandler from being loaded. If the option is not used, the StaticFilesHandler will be used (as it is currently on trunk at r14509).
This seems like a more appropriate solution than using django.conf.settings, since it only affects the "runserver" manage command.
If this patch needs additional tests or documentation, I'd be happy to help with that as well.
comment:4 by , 14 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
(In [14533]) Fixed #14524, #14582, #14617, #14665 and #14667 -- Tweaked staticfiles app.
- Updated StaticFilesHandler and AdminMediaHandler to make use of the 404 handler if needed.
- Updated runserver management command to serve static files only in DEBUG mode (or if specified the --insecure option) and if the staticfiles app is in INSTALLED_APPS. Also added an option to disable serving completely (--nostatic).
- Added check in debug mode if STATICFILES_* settings are different to MEDIA_* settings.
- Removed a faulty PendingDeprecationWarning in AdminMediaHandler that is triggered every time runserver is used.
- Fixed an issue with the modification time checks when running collectstatic.
- Extended and refined documentation.
Thanks to everyone for input, especially to Carl Meyer, Ted Kaemming and
Adam Vandenberg for patches.
Also brought up on django-dev: http://groups.google.com/group/django-developers/browse_thread/thread/c11289bdadceac7b#