Django

Code

Changeset 9165

Show
Ignore:
Timestamp:
10/06/08 03:29:05 (3 months ago)
Author:
mtredinnick
Message:

Fixed #8688 -- Added a note about using a settings variable for the static
media viewer with the development server. Based on a suggestion from trodrigues.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/docs/howto/static-files.txt

    r8506 r9165  
    3939To use it, just put this in your :ref:`URLconf <topics-http-urls>`:: 
    4040 
    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'}), 
    4243 
    4344...where ``site_media`` is the URL where your media will be rooted, and 
     
    5758      fall under the document root. 
    5859 
     60Of 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 
     62settings file and use the setting value there. That will allow you and 
     63other developers working on the code to easily change the value as 
     64required. 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}), 
    5972 
    6073Directory listings 
     
    6780For example:: 
    6881 
    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}), 
    7084 
    7185You can customize the index view by creating a template called