32👍
Your answer is that unless ADMIN_MEDIA_PREFIX
explicitly sets a domain
the runserver command will serve out the admin media files from contrib.admin.
I got burned by this magic behaviour, too. There was a ticket for this (Ticket #8336), but the design decision was to leave the convenience and confusion as it is.
So to serve your admin media (for using grappelli or whatever admin skin you want to use) from your directories with the runserver
command you have to use something like:
MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'media/')
ADMIN_MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'admin-media/')
MEDIA_URL = '/site-media/'
ADMIN_MEDIA_PREFIX = 'http:/localhost:8000/admin-media/'
I hope I am resurrecting the correct question here. Apologies in advance.
3👍
It is advised to run the dev server a little bit different [1]
python manage.py runserver mydomain.com:8000 –adminmedia=/path/to/your/admin/media/
[1] http://code.google.com/p/django-grappelli/wiki/Installation
2👍
Try
(r’^admin_media/(.*)’, ‘django.views.static.serve’, {‘document_root’ : ‘django/contrib/admin/media/’, ‘show_indexes’ : True}),
in your urls.py file. And change your
ADMIN_MEDIA_PREFIX = '/admin_media/'
- Django render_to_string() ignores {% csrf_token %}
- Sending a message to a single user using django-channels
2👍
I just fixed a similar bug in my test site. ADMIN_MEDIA_PREFIX and MEDIA_URL should never be the same, see the following note in the docs:
Make sure to use a trailing slash, and
to have this be different from the
MEDIA_URL setting (since the same URL
cannot be mapped onto two different
sets of files).
- Django is very slow on my machine
- How can I make a fixture out of QuerySet in django?
- How do I simulate connection errors and request timeouts in python unit tests
1👍
Try changing:
ADMIN_MEDIA_PREFIX = '/static/media/'
This assumes that your MEDIA_ROOT/media/ directory contains the admin media folder (which is what I understood from your question).
- Sending a message to a single user using django-channels
- How can I automatically let syncdb add a column (no full migration needed)
- Managing multiple settings.py files
- Django. Error message for login form
1👍
Since staticfiles inclusion into trunk, (circa 1.3 I believe), the ADMIN_MEDIA_PREFIX magic is no longer used.
Nowadays, runserver assumes your STATIC_URL + ‘admin/’. It secretly and silently intercepts your requests, ignores all your urlconf’s, and tries to make you go mad.
0👍
Try to Use STATICFILES_DIRS as blow
# Additional locations of static files
STATICFILES_DIRS = (
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
("images", os.path.join(STATIC_ROOT,'images').replace('\\','/')),
("css", os.path.join(STATIC_ROOT,'css').replace('\\','/')),
("js", os.path.join(STATIC_ROOT,'js').replace('\\','/')),
)
Have a goodluck!
- Create a canonical "parent" product in Django Oscar programmatically
- What is query.clone(), queryset.clone() for in django?
- You cannot add messages without installing django.contrib.messages.middleware.MessageMiddleware