我在调试模式下使用 Django 的内置 Web 服务器。
这是我的一部分settings.py
:
STATIC_ROOT = '/home/user/static_root'
STATIC_URL = '/static/'
STATICFILES_DIRS = (
'/abs/path/to/static/dir',
)
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)
如果我访问http://localhost:8000/static/png/
,我希望看到可用的文件列表/abs/path/to/static/dir/png
。相反,我收到 404 错误“此处不允许目录索引”。
现在,如果我直接访问文件,例如http://localhost:8000/static/png/test.png
,它可以工作。
我已经检查了一些答案(here)但没有成功。
那么,有谁知道如何配置 Django 以使staticfiles
应用程序列出目录内容?