Opened 16 years ago

Closed 15 years ago

#8336 closed (wontfix)

runserver option for disabling admin static files serving

Reported by: jakub_vysoky Owned by: nobody
Component: runserver Version: dev
Severity: Keywords: admin media runserver
Cc: Triage Stage: Design decision needed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


Okay, it's handy not to worry about admin media files static serving, when running simple dev server..

But if you want to do something special with admin media files, like not touching the original ones in django.contrib.admin and add some of your own, like we do with very simple static serving view (serve from one dir and fallback to another), you must set ADMIN_MEDIA_PREFIX = 'http://localhost:8000', which is not very portable solution, or symlink files from various dirs and let runserver serve admin static files from there.

If people have in their something for static media serving when DEBUG == True - why not to have there the same for admin?

I'll attach patch that adds an option for runserver management command which gives you the chance just to disable builtin magical serving.

Attachments (1)

8336-disable_admin_media_serving-8354.diff (1.7 KB ) - added by jakub_vysoky 16 years ago.
option for disabling admin media serving

Download all attachments as: .zip

Change History (9)

by jakub_vysoky, 16 years ago

option for disabling admin media serving

comment:1 by Jeff Anderson, 16 years ago

Component: runserver
Triage Stage: UnreviewedDesign decision needed

It sounds like you are looking for --admin-media=ADMIN_MEDIA_PATH option. You can point to whatever directory you want for serving admin media files.

I'm marking this as DDN because disabling the admin media serving might be useful for some people, though I'd be inclined to not include such a feature.

comment:2 by jakub_vysoky, 16 years ago

thanks for reading this ticket ;))

I know this option, but if you want no to touch django.contrib.admin files and add your own (eg.: in another repository) you have to:

symlink files from various dirs and let runserver serve admin static files from there

comment:3 by Malcolm Tredinnick, 16 years ago

Resolution: wontfix
Status: newclosed

That's correct. That is all you have to do.

This is a bit of a borderline case and I can see that some people will want to do this, but it's also just not that common a use to require expending a lot of effort. The existing solution takes 60 seconds to set up. We've documented how to do it and it works now.

comment:4 by jakub_vysoky, 16 years ago


But doesn't it look a bit uncomplete? If there is such thing like magical autoserving admin media files and if there is way to change directory of serving these things, that there is no way to disabling this feature?

Thanks anyway ;).

comment:5 by anonymous, 16 years ago

This bit of magic just cost me an hour of head scratching. I must have missed the documentation that says django-admin runserver will serve the built-in admin media no matter what you set ADMIN_MEDIA_PREFIX to (or so it seems?). Since there is no CSS fallback system (ala the template hierarchical lookup system) it makes sense to just copy the whole admin media to another directory and edit it directly to avoid messing up django's installed admin media used by other apps. I don't see how to do this except with the http://localhost trick proposed above. At the very least this should be documented better, magic is for Rails :-)

comment:6 by Almad, 15 years ago

Ran into that too :]

comment:7 by anonymous, 15 years ago

Resolution: wontfix
Status: closedreopened

Burned several hours scratching my head with this on multiple occasions as well. In DEBUG mode I have my media/ served with the django static serve in, and admin/ is a subfolder of that. However this django 'feature' overrides my media/admin/ with the django builtins.

Re-opening since this 'feature' is affecting a lot of people. This silent magic overriding of media directories is a really bad idea, and none of the proposed workarounds are useful. Having to type --adminmedia each time is a really horrible idea; if I work on something else for a week, then come back to it, I always forget, and burn yet another hour wondering why my customizations aren't showing up.

At the VERY least, my should override django's magic, not the other way around. If I'm specifying a media/ folder, obviously I will need admin/ in it on production, so django should assume I will have it set up the same way in development.

comment:8 by Alex Gaynor, 15 years ago

Resolution: wontfix
Status: reopenedclosed

Please don't reopen tickets closed by a commiter, if you disagree with the decision take it to the django-developers mailing list.

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