python-django 静态文件设置

python-django

静态文件路径设置

urlpatterns = patterns('',
    url(r'^css/(?P<path>.*)$', 'django.views.static.serve', {'document_root': '/usr/share/nginx/www/pythonweb/mysite/mysite/css'}),
    url(r'^js/(?P<path>.*)$', 'django.views.static.serve', {'document_root': '/usr/share/nginx/www/pythonweb/mysite/mysite/js'}),
    url(r'^images/(?P<path>.*)$', 'django.views.static.serve', {'document_root': '/usr/share/nginx/www/pythonweb/mysite/mysite/images'}),
	url(r'^hello/$', 'mysite.views.hello', name='hello'),
	url(r'^time/$', 'mysite.time.current_datetime', name='current_datetime'),
	url(r'^$', 'mysite.views.home', name='home'),
	url(r'^time/plus/(\d{1,2})/$', 'mysite.views.hours_ahead',name='hours_ahead'),
    url(r'^meta/$', 'mysite.views.display_meta',name='display_meta'),
    url(r'^search-form/$', 'mysite.books.views.search_form',name='search_form'),
    url(r'^search/$', 'mysite.books.views.search',name='search'),
    url(r'^contact/$', 'mysite.contact.views.contact',name='contact'),
    # Examples:
    # url(r'^$', 'mysite.views.home', name='home'),
    # url(r'^mysite/', include('mysite.foo.urls')),

    # Uncomment the admin/doc line below to enable admin documentation:
    #url(r'^admin/doc/', include('django.contrib.admindocs.urls')),

    # Uncomment the next line to enable the admin:
    url(r'^admin/', include(admin.site.urls)),
)

在html文件中直接可以调用

<link rel="stylesheet" type="text/css" media="screen" href="/css/base.css" />

你可能感兴趣的:(python-django 静态文件设置)