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: 562

Hello.

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:

  1. Install django-pagination without any problems. When I do in python import pagination, it's work well.

  2. Added pagination to INSTALLED_APP in settings.py:

    INSTALLED_APPS = ( # ..., 'pagination', )

  3. 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" )

  4. Also add to settings.py middleware:

    MIDDLEWARE_CLASSES = ( # ... 'pagination.middleware.PaginationMiddleware', )

  5. Add to top in views.py:

    from django.template import RequestContext

  6. 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

Related posts about django

Related posts about paginate