Ticket #1700: generic_views.txt.diff
File generic_views.txt.diff, 1.9 KB (added by , 19 years ago) |
---|
-
docs/generic_views.txt
35 35 from django_website.apps.blog.models import Entry 36 36 37 37 info_dict = { 38 ' model': Entry,38 'queryset': Entry.objects.all(), 39 39 'date_field': 'pub_date', 40 40 } 41 41 … … 47 47 (r'^/?$', 'archive_index', info_dict), 48 48 ) 49 49 50 As you can see, this URLconf defines a few options in ``info_dict``. ``'model'`` 51 tells the generic view which model to use (``Entry``, in this case), as well as 52 some extra information. 50 As you can see, this URLconf defines a few options in ``info_dict``. 51 ``'queryset'`` tells the generic view which objects to use (all of the 52 ``Entry`` objects, in this case), as well as some extra information (it is 53 used by the view to determine the model being used, for example). 53 54 54 55 Documentation of each generic view follows, along with a list of all keyword 55 56 arguments that a generic view expects. Remember that as in the example above, 56 57 arguments may either come from the URL pattern (as ``month``, ``day``, 57 58 ``year``, etc. do above) or from the additional-information dictionary (as for 58 `` model``, ``date_field``, etc.).59 ``queryset``, ``date_field``, etc.). 59 60 60 Most generic views require the ``model`` key, which is your model class (*not* 61 an instance of the class). 61 Most generic views require the ``queryset`` key, which is a ``QuerySet`` 62 instance (*not* an instance of the class); see the `database API docs`_ 63 for more information about query sets. 62 64 63 65 Using "simple" generic views 64 66 ============================ … … 446 448 ``template_object_name`` parameter. (See above.) For example, if 447 449 ``template_object_name`` is ``foo``, the variable will be ``foo`` 448 450 instead of ``object``. 451