djangodjango-1.5

How to configure Django's "staticfiles" app to list directory contents?


I'm using Django's built-in web server, in DEBUG mode.

This is part of my 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',
)

If I access http://localhost:8000/static/png/, I would expect to see a list of files available in /abs/path/to/static/dir/png. Instead I get a 404 error "Directory indexes are not allowed here."

Now if I access the files directly, e.g. http://localhost:8000/static/png/test.png, it works.

I've already checked some answers (here) without success.

So, does anyone know how to configure Django such that the staticfiles app lists directory contents?


Solution

  • 'show_indexes': True
    

    As per the documentation