Changeset 3071
- Timestamp:
- 06/03/06 17:06:48 (2 years ago)
- Files:
-
- django/trunk/django/views/generic/list_detail.py (modified) (2 diffs)
- django/trunk/docs/generic_views.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/views/generic/list_detail.py
r3070 r3071 5 5 from django.core.exceptions import ObjectDoesNotExist 6 6 7 def object_list(request, queryset, paginate_by=None, allow_empty=False,8 template_name=None, template_loader=loader,7 def object_list(request, queryset, paginate_by=None, page=None, 8 allow_empty=False, template_name=None, template_loader=loader, 9 9 extra_context=None, context_processors=None, template_object_name='object', 10 10 mimetype=None): … … 39 39 if paginate_by: 40 40 paginator = ObjectPaginator(queryset, paginate_by) 41 page = request.GET.get('page', 1) 41 if not page: 42 page = request.GET.get('page', 1) 42 43 try: 43 44 page = int(page) django/trunk/docs/generic_views.txt
r3039 r3071 642 642 * ``paginate_by``: An integer specifying how many objects should be 643 643 displayed per page. If this is given, the view will paginate objects with 644 ``paginate_by`` objects per page. The view will expect a ``page`` query 645 string (GET) parameter containing a zero-indexed page number. 644 ``paginate_by`` objects per page. The view will expect either a ``page`` 645 query string parameter (via ``GET``) containing a zero-indexed page 646 number, or a ``page`` variable specified in the URLconf. See 647 "Notes on pagination" below. 646 648 647 649 * ``template_name``: The full name of a template to use in rendering the … … 711 713 * ``hits``: The total number of objects across *all* pages, not just this 712 714 page. 715 716 Notes on pagination 717 ~~~~~~~~~~~~~~~~~~~ 718 719 If ``paginate_by`` is specified, Django will paginate the results. You can 720 specify the page number in the URL in one of two ways: 721 722 * Use the ``page`` parameter in the URLconf. For example, this is what 723 your URLconf might look like:: 724 725 (r'^objects/page(?P<page>[0-9]+)/$', 'object_list', dict(info_dict)) 726 727 * Pass the page number via the ``page`` query-string parameter. For 728 example, a URL would look like this: 729 730 /objects/?page=3 731 732 In both cases, ``page`` is 1-based, not 0-based, so the first page would be 733 represented as page ``1``. 713 734 714 735 ``django.views.generic.list_detail.object_detail``
