#10636 closed (fixed)
Development server fails if settings module does not define ADMIN_MEDIA_PREFIX
Reported by: | Owned by: | Jannis Leidel | |
---|---|---|---|
Component: | django-admin.py runserver | Version: | dev |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | yes |
Needs tests: | yes | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I defined ADMIN_MEDIA_PREFIX = "" in my settings module and found that this caused the development server to not work: all requests for URLs returned a "URL not found", and the server did not log the requests to stdout as it normally does. Setting ADMIN_MEDIA_PREFIX to any nonempty string fixes this.
Change History (11)
follow-up: 2 comment:1 by , 16 years ago
comment:2 by , 16 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
Replying to kmtracey:
OK, your explanation is good, so I've changed my ticket to "invalid" (I hope that's the right thing). My naive expectation was that, since I didn't have any admin media, that it was better to not define a place for the server to look for it, but, as you've explained, the side-effect was that all URLs were interpreted requests for admin media. Maybe a little extra documentation would be in order?
comment:3 by , 15 years ago
Resolution: | invalid |
---|---|
Status: | closed → reopened |
I don't see why this is invalid. If the server requires that ADMIN_MEDIA_PREFIX be non-empty, then that should be checked and an error should be reported. If an exception was thrown that would be fine, but currently there is zero indication of what the actual problem is.
comment:4 by , 15 years ago
Resolution: | → invalid |
---|---|
Status: | reopened → closed |
I agree with Karen, this is doing exactly what it says, any request that begins with that is routed to admin media handling.
comment:5 by , 14 years ago
Resolution: | invalid |
---|---|
Status: | closed → reopened |
Version: | 1.0 → 1.2 |
From kmtracey in #14607:
It is a duplicate: #10636 is the same. Why did you want to set ADMIN_MEDIA_PREFIX to an empty value? Perhaps the docs could warn to not do that, or some check could be put in to raise ImproperlyConfigured if that is done, by I'm a little mystified as to why people are doing this. If you really want to pursue getting something changed here, please reopen #10636 and provide a concrete suggestion for how to improve matters (and please try the current trunk behavior, since it may have changed recently given the static file changes).
Leaving ADMIN_MEDIA_PREFIX is certainly an incorrect configuration, but one that people may try when attempting to serve admin media files. People are doing it accidentally, not deliberately. The problem is that despite DEBUG being set to true, no helpful trace is provided, just the simple 404.
Because it manifests in the user's browser as a standard 404, this failure mode makes some people think there might be a problem with their django or webserver setup, rather than a problem with their code. It appears like the web browser is unable to reach the webserver.
Concrete suggestion for improvement: If ADMIN_MEDIA_PREFIX is empty, output an error trace page saying "ADMIN_MEDIA_PREFIX in settings.py is empty. This is probably not what you want to do." Additionally, the docs should warn against this configuration.
comment:6 by , 14 years ago
For further clarity: It is not that the Admin media don't serve with a 404... It is that the entire project goes 404, even non-admin pages.
comment:7 by , 14 years ago
Owner: | changed from | to
---|---|
Status: | reopened → new |
comment:8 by , 14 years ago
Component: | Uncategorized → django-admin.py runserver |
---|---|
milestone: | → 1.3 |
Needs documentation: | set |
Needs tests: | set |
Owner: | changed from | to
Status: | new → assigned |
Triage Stage: | Unreviewed → Accepted |
Version: | 1.2 → SVN |
comment:9 by , 14 years ago
Owner: | changed from | to
---|---|
Status: | assigned → new |
comment:10 by , 14 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
So don't do that? The development server has a built-in admin media server that keys off of ADMIN_MEDIA_PREFIX -- any url that beings with ADMIN_MEDIA_PREFIX is routed to the built-in server that serves the files in the admin media directory. So if you set ADMIN_MEDIA_PREFIX to "", I'd guess everything gets routed to the built-in media server, which of course isn't going to work. It probably won't even be able to server the admin media files since the setting is expected (as noted in the comment for it in settings.py) to include a trailing slash, and you left even that out. It isn't clear what you expect to happen instead?