Changeset 9165
- Timestamp:
- 10/06/08 03:29:05 (3 months ago)
- Files:
-
- django/trunk/docs/howto/static-files.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/docs/howto/static-files.txt
r8506 r9165 39 39 To use it, just put this in your :ref:`URLconf <topics-http-urls>`:: 40 40 41 (r'^site_media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': '/path/to/media'}), 41 (r'^site_media/(?P<path>.*)$', 'django.views.static.serve', 42 {'document_root': '/path/to/media'}), 42 43 43 44 ...where ``site_media`` is the URL where your media will be rooted, and … … 57 58 fall under the document root. 58 59 60 Of course, it's not compulsory to use a fixed string for the 61 ``'document_root'`` value. You might wish to make that an entry in your 62 settings file and use the setting value there. That will allow you and 63 other developers working on the code to easily change the value as 64 required. For example, if we have a line in ``settings.py`` that says:: 65 66 STATIC_DOC_ROOT = '/path/to/media' 67 68 ...we could write the above :ref:`URLconf <topics-http-urls>` entry as:: 69 70 (r'^site_media/(?P<path>.*)$', 'django.views.static.serve', 71 {'document_root': settings.STATIC_DOC_ROOT}), 59 72 60 73 Directory listings … … 67 80 For example:: 68 81 69 (r'^site_media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': '/path/to/media', 'show_indexes': True}), 82 (r'^site_media/(?P<path>.*)$', 'django.views.static.serve', 83 {'document_root': '/path/to/media', 'show_indexes': True}), 70 84 71 85 You can customize the index view by creating a template called
