当前位置:   article > 正文

Django 中如何使用css 详细解析_django 解析本地css

django 解析本地css

按照如下的设置来做就可以了,讲的非常清楚:

settings.py:

  1. MEDIA_ROOT = 'C:/Server/Projects/project_name/static/'
  2. MEDIA_URL = '/static/'
  3. ADMIN_MEDIA_PREFIX = '/media/'

urls.py:

  1. from django.conf import settings
  2. ...
  3. if settings.DEBUG:
  4. urlpatterns += patterns('',
  5. (r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}),
  6. )

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" 
 
  1. 转自:
  2. http://stackoverflow.com/questions/446026/django-how-do-you-serve-media-stylesheets-and-link-to-them-within-templates
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/203678
推荐阅读
相关标签
  

闽ICP备14008679号