Django serving from media/ but not static/
I had my static files being served form media i.e., the tree looked like this:
media/ /css /js /images
with this in my url conf:
if settings.SERVE_MEDIA_FROM_DJANGO:
urlpatterns += patterns('',
(r'^media/(?P<path>.*)$', 'django.views.static.serve', {'documen开发者_StackOverflowt_root': r'media'}),
(r'^tiny_mce/(?P<path>.*)$', 'django.views.static.serve', { 'document_root': r'media/js/tiny_mc' }),
)
I then switched it to this:
static/ /css /js /images
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' }),
)
I don't understand why changing media to static has stopped django from serving static files, any ideas?
Cheers,
J
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.
You can find more information about serving static files in Production here.
精彩评论