views:

168

answers:

1

It looks like this template tag works like a charm for most people:

http://blog.localkinegrinds.com/2007/09/06/digg-style-pagination-in-django/

For some reason I get this error: Caught an exception while rendering: 'is_paginated'

I use this template tag in my template like so:

{% load digg_paginator %}
{% digg_paginator %}

Where digg_paginator.py is in my app/templatetags folder and the included template context digg_paginator.html is in my app/templates folder. The queryset that needs pagination is called 'destinations'. If i just specify {% digg_paginator %}, how does it know what variable to paginate? I feel I am missing something important here or just plain stupid :P

Someone please help, or explain to me how this should be done. Thanks

+3  A: 

If you read the description of that template tag, it says it is built to paginate using the built-in generic views:

Like the PaginatorTag, this tag is a very basic inclusion tag that builds on the variables already set on the context when paginating with the generic object_list view. There are a few additional context variables created...

The is_paginated variable is setup by the generic view (look at the template_context section of the django documentation linked earlier).

Updated

To use that paginator, you will need to modify your view to use the generic view functionality in Django. Since you haven't provided the code for your views or urls I can't give you any concrete suggestions on how to change your code.

If you follow through the Django Tutorial, in part 4 (the last section) they walk you through modifying the simple application that you built in the previous sections to use generic views. The strength of using generic views is that it automatically handles most of the brain dead index() and detail() view code:

These views represent a common case of basic Web development: getting data from the database according to a parameter passed in the URL, loading a template and returning the rendered template. Because this is so common, Django provides a shortcut, called the "generic views" system.

Lance McNearney
Thanks for ur reply, I tried going through the documentation but it will take a while for me to understand! Can you point to a line in the code where I might be doing things wrong?
ninja123
Awesme thanks bud
ninja123
sorry, was sidetracked I will definitely accept it as soon as I implement it ... which is about right now... Thanks man
ninja123
Awesome works now!
ninja123