【发布时间】:2012-09-03 10:04:52
【问题描述】:
在 settings.py 中,我得到了 media_url = '/media/' 和 static_url = '/static/'
在我得到的 urls.py 中:
(r'^media/(?P<path>.*)$', 'django.views.static.serve',{'document_root': settings.MEDIA_ROOT,'show_indexes': True}),
(r'^static/(?P<path>.*)$', 'django.views.static.serve',{'document_root': settings.STATIC_ROOT,'show_indexes': True}),
当我尝试打开 localhost/media/ 时,django 会正确加载放置在媒体目录中的图像。但是当我尝试转到 /static/ 时,我得到了:
Request Method: GET
Request URL: localhost/static/
Directory indexes are not allowed here.
但是,当我在 setting.py 中更改 static_url = '/sssstatic/' 时,localhost/static/ 工作正常。
这里有什么问题?
【问题讨论】:
标签: python django django-urls django-settings