django+python開發的網站怎麼靜態引用img圖片
阿新 • • 發佈:2019-01-28
html中引用圖片路徑:
<p><img src="/site_media/abc.gif" mce_src="site_media/abc.gif" ></p>
url.py新增配置:
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'csvt02.views.home', name='home'),
# url(r'^csvt02/', include('csvt02.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)),
url(r'^index/$','blog.views.index'),
(r'^site_media/(?P<path>.*)','django.views.static.serve',{'document_root':'E:/workspace/csvt02/img'}),
)