diff options
| author | Adrian Holovaty <adrian@holovaty.com> | 2005-11-27 15:28:19 +0000 |
|---|---|---|
| committer | Adrian Holovaty <adrian@holovaty.com> | 2005-11-27 15:28:19 +0000 |
| commit | ed97929b91c899fd880460e228d7c2622213980b (patch) | |
| tree | 16995a7ae0a4fb4aa1d5bc4f7af7a8ccaef71f20 /docs/static_files.txt | |
| parent | c8e98f4cdddaf4ca82a0c02581d036d6ddf1a614 (diff) | |
Added a 'Directory listings' section to docs/static_files.txt
git-svn-id: http://code.djangoproject.com/svn/django/trunk@1457 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs/static_files.txt')
| -rw-r--r-- | docs/static_files.txt | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/docs/static_files.txt b/docs/static_files.txt index 034cb976a3..333bb12e22 100644 --- a/docs/static_files.txt +++ b/docs/static_files.txt @@ -36,6 +36,8 @@ Just put this in your URLconf_:: ...where ``site_media`` is the URL where your media will be rooted, and ``/path/to/media`` is the filesystem root for your media. +You must pass a ``document_root`` parameter to indicate the filesystem root. + Examples: * The file ``/path/to/media/foo.jpg`` will be made available at the URL @@ -49,6 +51,43 @@ Examples: .. _URLconf: http://www.djangoproject.com/documentation/url_dispatch/ +Directory listings +================== + +Optionally, you can pass a ``show_indexes`` parameter to the ``static.serve`` +view. This is ``False`` by default. If it's ``True``, Django will display file +listings for directories. + +Example:: + + (r'^site_media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': '/path/to/media', 'show_indexes': True}), + +You can customize the index view by creating a template called +``static/directory_index``. That template gets two objects in its context: + + * ``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:: + + <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> + <head> + <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> + <meta http-equiv="Content-Language" content="en-us" /> + <meta name="robots" content="NONE,NOARCHIVE" /> + <title>Index of {{ directory }}</title> + </head> + <body> + <h1>Index of {{ directory }}</h1> + <ul> + {% for f in file_list %} + <li><a href="{{ f }}">{{ f }}</a></li> + {% endfor %} + </ul> + </body> + </html> + Limiting use to DEBUG=True ========================== |
