问题描述
我的静态文件由媒体提供,即树状如下:
I had my static files being served form media i.e., the tree looked like this:
media /
/ css
/ js
/ images
media//css/js/images
在我的url conf中:
with this in my url conf:
if settings.SERVE_MEDIA_FROM_DJANGO:
urlpatterns += patterns('',
(r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': r'media'}),
(r'^tiny_mce/(?P<path>.*)$', 'django.views.static.serve', { 'document_root': r'media/js/tiny_mc' }),
)
然后我将其切换到:
static /
/ css
/ js
/ images
static//css/js/images
这个在我的url conf:
with this in my url conf:
if settings.SERVE_MEDIA_FROM_DJANGO:
urlpatterns += patterns('',
(r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': r'static'}),
(r'^tiny_mce/(?P<path>.*)$', 'django.views.static.serve', { 'document_root': r'static/js/tiny_mc' }),
)
我不明白为什么要将媒体变成静态已经停止django提供静态文件,任何想法?
I don't understand why changing media to static has stopped django from serving static files, any ideas?
干杯,
J
推荐答案
使用最新的Django?最新的Django只提供开发环境中的静态文件夹。您必须将其设置和别名/静态到文件夹(在Apache上)才能静态。
Using latest Django? The latest Django only serves the static folder in dev environment. You have to set it up and alias /static to a folder (on Apache) to serve static.
您可以在Production 。
You can find more information about serving static files in Production here.
这篇关于Django从媒体/但不是静态/的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!