赞
踩
按照如下的设置来做就可以了,讲的非常清楚:
settings.py:
- MEDIA_ROOT = 'C:/Server/Projects/project_name/static/'
- MEDIA_URL = '/static/'
- ADMIN_MEDIA_PREFIX = '/media/'
urls.py:
- from django.conf import settings
- ...
- if settings.DEBUG:
- urlpatterns += patterns('',
- (r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}),
- )
template file:
<link rel="stylesheet" type="text/css" href="/static/css/style.css" />
With the file located here:
"C:/Server/Projects/project_name/static/css/style.css"
- 转自:
- http://stackoverflow.com/questions/446026/django-how-do-you-serve-media-stylesheets-and-link-to-them-within-templates
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。