python django media_root
If I use the code below it will find my base.css under the project folder:
<link rel="stylesheet" type="text/css" href="{% block stylesheet %}/media/a/admin/css/base.css{% endblock %}" />
MEDIA_ROOT = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'media')
MEDIA_URL = '/media/a/'
(r'^media/(?P开发者_Go百科<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}),
However, if I use the code below, it will go to the \Python25\Lib\site-packages\django\contrib\admin\media\css
to find base.css:
<link rel="stylesheet" type="text/css" href="{% block stylesheet %}/a/admin/css/base.css{% endblock %}" />
MEDIA_ROOT = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'media')
MEDIA_URL = '/a/'
(r'^a/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}),
Does anyone know the reason why this happens?
Thanks~~
I'm guessing you have your ADMIN_MEDIA_PREFIX = '/a/admin/'
http://docs.djangoproject.com/en/dev/ref/settings/#admin-media-prefix
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).
my mistake:
i haven't set the "runsever --adminmedia" command
精彩评论