Login

Snippets by piratus

Snippet List

Pagination shortcut

This is a function wrapping the code from [example](http://docs.djangoproject.com/en/dev/topics/pagination/#using-paginator-in-a-view) from django docs. The required parameters are: `request` which is a `Request` object from a view, and `objects` - a list of objects to paginate. You may want to tune number of items per page by specifying `count` and the name of a GET parameter through `param_name` To use it in your view just wrap the paginated object into a function for example: def someview(request): articles = Article.objects.all() ... some other logics ... return render_to_response(template, {'articles': paginate(request, articles)}

  • pagination
Read More

piratus has posted 1 snippet.