In Django-pagination Paginate does not working...
Posted
by mosg
on Stack Overflow
See other posts from Stack Overflow
or by mosg
Published on 2010-06-17T07:08:50Z
Indexed on
2010/06/17
7:13 UTC
Read the original article
Hit count: 602
Hello.
- Python 2.6.2
- django-pagination 1.0.5
Question: How to force pagination work correctly? The problem is that {% paginate %}
does not work, but other {% load pagination_tags %}
and {% autopaginate object_list 10 %}
works!
Error message appeared, when I add {% paginate %}
into html page:
TemplateSyntaxError at /logging
Caught an exception while rendering: pagination/pagination.html
What I have done:
Install django-pagination without any problems. When I do in python
import pagination
, it's work well.Added pagination to INSTALLED_APP in settings.py:
INSTALLED_APPS = ( # ..., 'pagination', )
Added in settings.py:
TEMPLATE_CONTEXT_PROCESSORS = ( "django.core.context_processors.auth", "django.core.context_processors.debug", "django.core.context_processors.i18n", "django.core.context_processors.media", "django.core.context_processors.request" )
Also add to settings.py middleware:
MIDDLEWARE_CLASSES = ( # ... 'pagination.middleware.PaginationMiddleware', )
Add to top in views.py:
from django.template import RequestContext
And finally add to my HTML template page lines:
{% load pagination_tags %} ... {% autopaginate item_list 50 %} {% for item in item_list %} ... {% endfor %} {% paginate %}
Thanks.
PS: some edits required, because I can't django code style work well here :)
© Stack Overflow or respective owner