Code

Opened 9 years ago

Closed 9 years ago

Last modified 8 years ago

#110 closed enhancement (fixed)

Documentation on pagination needed

Reported by: maurycy Owned by: jacob
Component: Documentation Version:
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Third path of tutorial should show views that don't return output and polls list with paging support.

Attachments (0)

Change History (4)

comment:1 Changed 9 years ago by anonymous

  • Summary changed from Third path of tutorial suggestions to Tutorial suggestions

comment:2 Changed 9 years ago by jacob

  • Severity changed from normal to enhancement
  • Status changed from new to assigned
  • Summary changed from Tutorial suggestions to Documentation on pagination needed

Views that don't return output are documented in a few places -- see anywhere that uses HttpResponseRedirect; changing this ticket to reflect that pagination needs documentation

comment:3 Changed 9 years ago by maurycy

BTW. django.views.generic.list_details.object_list seems to be a good example of pagination:

def object_list(request, app_label, module_name, paginate_by=None, allow_empty=False, template_name=None, extra_lookup_kwargs={}, extra_context=None):
    mod = models.get_module(app_label, module_name)
    lookup_kwargs = extra_lookup_kwargs.copy()
    if paginate_by:
        paginator = ObjectPaginator(mod, lookup_kwargs, paginate_by)
        page = request.GET.get('page', 0)
        try:
            object_list = paginator.get_page(page)
        except InvalidPage:
            raise Http404
        page = int(page)
        c = Context(request, {
            'object_list': object_list,
            'is_paginated' : True,
            'results_per_page' : paginate_by,
            'has_next': paginator.has_next_page(page),
            'has_previous': paginator.has_previous_page(page),
            'page': page + 1,
            'next': page + 1,
            'previous': page - 1,
            'pages': paginator.pages,
        })
    else:
        object_list = mod.get_list(**lookup_kwargs)
        c = Context(request, {
            'object_list' : object_list,
            'is_paginated' : False
        })

comment:4 Changed 9 years ago by maurycy

  • Resolution set to fixed
  • Status changed from assigned to closed

We can assume that documentation of generic views describes pagination well.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.