diff --git a/django/views/static.py b/django/views/static.py index c8ebf0c22d..8355950fe0 100644 --- a/django/views/static.py +++ b/django/views/static.py @@ -91,7 +91,8 @@ DEFAULT_DIRECTORY_INDEX_TEMPLATE = """ def directory_index(path, fullpath): try: - t = loader.get_template('static/directory_index.html') + t = loader.select_template(['static/directory_index.html', + 'static/directory_index']) except TemplateDoesNotExist: t = Template(DEFAULT_DIRECTORY_INDEX_TEMPLATE, name='Default directory index template') files = [] diff --git a/docs/howto/static-files.txt b/docs/howto/static-files.txt index b0b76bd78b..bff472fc3f 100644 --- a/docs/howto/static-files.txt +++ b/docs/howto/static-files.txt @@ -90,7 +90,7 @@ You can customize the index view by creating a template called * ``directory`` -- the directory name (a string) * ``file_list`` -- a list of file names (as strings) in the directory -Here's the default ``static/directory_index`` template: +Here's the default ``static/directory_index.html`` template: .. code-block:: html+django @@ -112,6 +112,14 @@ Here's the default ``static/directory_index`` template: +.. versionchanged:: 1.0.3 + Prior to Django 1.0.3, there was a bug in the view that provided directory + listings. The template that was loaded had to be called + ``static/directory_listing`` (with no ``.html`` extension). For backwards + compatibility with earlier versions, Django will still load templates with + the older (no extension) name, but it will prefer a the + ``directory_index.html`` version. + Limiting use to DEBUG=True ==========================