您的位置:首页 > Web前端 > CSS

Django 中如何使用css 详细解析

2012-06-19 14:16 531 查看
按照如下的设置来做就可以了,讲的非常清楚:

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"

 [/code]
转自:
http://stackoverflow.com/questions/446026/django-how-do-you-serve-media-stylesheets-and-link-to-them-within-templates
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: