Changeset 1256
- Timestamp:
- 11/15/05 18:25:48 (3 years ago)
- Files:
-
- django/trunk/docs/generic_views.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/docs/generic_views.txt
r1249 r1256 77 77 78 78 ``direct_to_template`` 79 Renders a given template using any extra parameters passed in the 80 urlpattern; requires the ``template`` argument. 81 79 Renders a given template, passing it a ``{{ params }}`` template variable, 80 which is a dictionary of the parameters captured in the URL. This requires 81 the ``template`` argument. 82 82 83 For example, given the following URL patterns:: 83 84 84 85 urlpatterns = patterns('django.views.generic.simple', 85 (r'^foo/$', 'direct_to_template', {'template' : 'foo_index'}),86 (r'^foo/(?P<id>\d+)/$', 'direct_to_template', {'template' : 'foo_detail'}),86 (r'^foo/$', 'direct_to_template', {'template': 'foo_index'}), 87 (r'^foo/(?P<id>\d+)/$', 'direct_to_template', {'template': 'foo_detail'}), 87 88 ) 88 89 89 90 ... a request to ``/foo/`` would cause the ``foo_index`` template to be 90 91 rendered, and a request to ``/foo/15/`` would cause the ``foo_detail`` 91 92 template to be rendered with a context variable ``{{ params.id }}`` that is 92 93 set to ``15``. 93 94 94 95 ``redirect_to`` 95 96 Issue a redirect to a given URL. 96 97 97 The given url may contain dict-style string formattingwhich will be98 The given URL may contain dict-style string formatting, which will be 98 99 interpolated against the params in the URL. For example, to redirect from 99 100 ``/foo/<id>/`` to ``/bar/<id>/``, you could use the following urlpattern:: … … 102 103 ('^foo/(?p<id>\d+)/$', 'redirect_to', {'url' : '/bar/%(id)s/'}), 103 104 ) 104 105 If the given url is ``None``, a HttpResponseGone(410) will be issued.105 106 If the given URL is ``None``, an ``HttpResponseGone`` (410) will be issued. 106 107 107 108 Using date-based generic views
