Serve admin-media from urls.py

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
###
# urls.py
###

import os

import django

...

admin_media_url = settings.ADMIN_MEDIA_PREFIX.lstrip('/') + '(?P<path>.*)$'
admin_media_path = os.path.join(django.__path__[0], 'contrib', 'admin', 'media')

urlpatterns = patterns('',
    url(r'^admin/', include(admin.site.urls)),
    url(r'^' + admin_media_url , 'django.views.static.serve', {
        'document_root': admin_media_path,
    }, name='admin-media'),
    ...
)

More like this

  1. Quiet runserver by danielroseman 2 years, 11 months ago
  2. Serve static media and indexes from app directories [Python2.5, Development only] by adamlofts 4 years, 9 months ago
  3. Better Static Image Serving With Fallback by menendez 3 years, 1 month ago
  4. Debug-only static serving by ludvig.ericson 5 years, 4 months ago
  5. pyserver -- runserver alias by presclark 5 years ago

Comments

(Forgotten your password?)