if settings.DEBUG: urlpatterns += patterns('', (r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}), )
再在settings.py中修改,
MEDIA_ROOT = 'xx' MEDIA_URL = '/media/' ADMIN_MEDIA_PREFIX = '/media/'
2. 获取文件,在xx.html中修改,
<a href="{{ xx.url }}">{{ xx.name }}</a>