Changeset 2790
- Timestamp:
- 04/28/06 22:04:00 (2 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/magic-removal/docs/static_files.txt
r1457 r2790 32 32 Just put this in your URLconf_:: 33 33 34 (r'^site_media/( ?P<path>.*)$', 'django.views.static.serve', {'document_root': '/path/to/media'}),34 (r'^site_media/(.*)$', 'django.views.static.serve', {'document_root': '/path/to/media'}), 35 35 36 36 ...where ``site_media`` is the URL where your media will be rooted, and … … 61 61 Example:: 62 62 63 (r'^site_media/( ?P<path>.*)$', 'django.views.static.serve', {'document_root': '/path/to/media', 'show_indexes': True}),63 (r'^site_media/(.*)$', 'django.views.static.serve', {'document_root': '/path/to/media', 'show_indexes': True}), 64 64 65 65 You can customize the index view by creating a template called … … 101 101 102 102 from django.conf.urls.defaults import * 103 from django.conf .settings import DEBUG103 from django.conf import settings 104 104 105 105 urlpatterns = patterns('', … … 110 110 ) 111 111 112 if DEBUG:112 if settings.DEBUG: 113 113 urlpatterns += patterns('', 114 114 (r'^site_media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': '/path/to/media'}), 115 115 ) 116 116 117 This code is straightforward. It imports the `DEBUG setting`_ and checks its118 value. If it evaluates to ``True``, then ``site_media`` will be associated with 119 the ``django.views.static.serve`` view. If not (``DEBUG == False``), then the 120 view won't be made available.117 This code is straightforward. It imports the settings and checks the value of 118 the ``DEBUG`` setting. If it evaluates to ``True``, then ``site_media`` will be 119 associated with the ``django.views.static.serve`` view. If not 120 (``DEBUG == False``), then the view won't be made available. 121 121 122 122 Of course, the catch here is that you'll have to remember to set ``DEBUG=False``
