runserver --insecure时如何提供媒体文件? [英] How to serve media file when runserver --insecure?
本文介绍了runserver --insecure时如何提供媒体文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当 runserver --insecure
它仅提供css和js以及图片,但我需要使用...提供媒体文件
It serves only css and js and image but i need to serve media file with ...
他们提到使用 cachefile
是不可能的,但是没有关于媒体的消息.
They mention it's not possible with cachefile
but no word about media.
推荐答案
您需要告诉它来提供媒体文件.在您的 urls.py
中:
You need to tell it to serve your media files. In your urls.py
:
from django.conf import settings
if settings.DEBUG == False:
urlpatterns += patterns('',
url(r'^media/(?P<path>.*)$', 'django.views.static.serve', {
'document_root': settings.MEDIA_ROOT,
}),
url(r'^static/(?P<path>.*)$', 'django.views.static.serve', {
'document_root': settings.STATIC_ROOT,
}),
)
这篇关于runserver --insecure时如何提供媒体文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文