Opened 16 years ago

Closed 14 years ago

Last modified 13 years ago

#10636 closed (fixed)

Development server fails if settings module does not define ADMIN_MEDIA_PREFIX

Reported by: Lee Phillips <lee@…> 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)

comment:1 by Karen Tracey, 16 years ago

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?

in reply to:  1 comment:2 by Lee Phillips <lee@…>, 16 years ago

Resolution: invalid
Status: newclosed

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 Tom von Schwerdtner, 15 years ago

Resolution: invalid
Status: closedreopened

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 Alex Gaynor, 15 years ago

Resolution: invalid
Status: reopenedclosed

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 dmlodecki@…, 14 years ago

Resolution: invalid
Status: closedreopened
Version: 1.01.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 dmlodecki@…, 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 Jannis Leidel, 14 years ago

Owner: changed from nobody to Jannis Leidel
Status: reopenednew

comment:8 by rasca, 14 years ago

Component: Uncategorizeddjango-admin.py runserver
milestone: 1.3
Needs documentation: set
Needs tests: set
Owner: changed from Jannis Leidel to rasca
Status: newassigned
Triage Stage: UnreviewedAccepted
Version: 1.2SVN

comment:9 by rasca, 14 years ago

Owner: changed from rasca to Jannis Leidel
Status: assignednew

comment:10 by Jannis Leidel, 14 years ago

Resolution: fixed
Status: newclosed

(In [14593]) Fixed #10636 -- Added check to make sure the ADMIN_MEDIA_PREFIX setting is properly set before serving files with the AdminMediaHandler.

comment:11 by Jacob, 13 years ago

milestone: 1.3

Milestone 1.3 deleted

Note: See TracTickets for help on using tickets.
Back to Top