当前位置:编程学习 > python >>

python-django 静态文件设置

python-django

静态文件路径设置

01
urlpatterns = patterns('',
02
    url(r'^css/(?P<path>.*)$', 'django.views.static.serve', {'document_root': '/usr/share/nginx/www/pythonweb/mysite/mysite/css'}),
03
    url(r'^js/(?P<path>.*)$', 'django.views.static.serve', {'document_root': '/usr/share/nginx/www/pythonweb/mysite/mysite/js'}),
04
    url(r'^images/(?P<path>.*)$', 'django.views.static.serve', {'document_root': '/usr/share/nginx/www/pythonweb/mysite/mysite/images'}),
05
    url(r'^hello/$', 'mysite.views.hello', name='hello'),
06
    url(r'^time/$', 'mysite.time.current_datetime', name='current_datetime'),
07
    url(r'^$', 'mysite.views.home', name='home'),
08
    url(r'^time/plus/(\d{1,2})/$', 'mysite.views.hours_ahead',name='hours_ahead'),
09
    url(r'^meta/$', 'mysite.views.display_meta',name='display_meta'),
10
    url(r'^search-form/$', 'mysite.books.views.search_form',name='search_form'),
11
    url(r'^search/$', 'mysite.books.views.search',name='search'),
12
    url(r'^contact/$', 'mysite.contact.views.contact',name='contact'),
13
    # Examples:
14
    # url(r'^$', 'mysite.views.home', name='home'),
15
    # url(r'^mysite/', include('mysite.foo.urls')),
16
 
17
    # Uncomment the admin/doc line below to enable admin documentation:
18
    #url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
19
 
20
    # Uncomment the next line to enable the admin:
21
    url(r'^admin/', include(admin.site.urls)),
22
)
在html文件中直接可以调用
<link rel="stylesheet" type="text/css" media="screen" href="/css/base.css" />

作者:张大鹏
补充:Web开发 , Python ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,