Browse files

[1.0.X] Revised r9567 slightly to be backwards compatible with versio…

…ns 1.0 - 1.0.2.

Also documented the change. We prefer to load directory_index.html for static
directory listings, but if you have the (older style) "directory_index"
template and no .html version, we'll load that. This should stop a bunch of
mysterious breakages when people upgrade to Django 1.0.3 or Django 1.1. Also
keeps the docs in sync with released code.

Fixed #9993.

Backport of r9725 from trunk.

git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
malcolmt committed Jan 9, 2009
1 parent 195a6ea commit 37260e046f438e4eb871b6b84cafbf4fcd4b92ea
Showing with 11 additions and 2 deletions.
  1. +2 −1 django/views/
  2. +9 −1 docs/howto/static-files.txt
@@ -91,7 +91,8 @@ def serve(request, path, document_root=None, show_indexes=False):
def directory_index(path, fullpath):
- 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 = []
@@ -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

0 comments on commit 37260e0

Please sign in to comment.