Django: autopaginate template tag causes "Caught an exception while rendering: 'request'"

The template tag "{% autopaginate list_name 15 %}" threw up a little in the mouth when I added it onto a new project.

Problem?

Apparently the following line threw an exception.

File "paginate/templatetags/pagination_tags.py", line 90, in render

The code throwing this error is:

try:
    page_obj = paginator.page(context['request'].page)
except InvalidPage:
    ...

Solution?

In your "settings.py", add the following.

TEMPLATE_CONTEXT_PROCESSORS = (
    'django.core.context_processors.request',
)

Whalla, problem solved.

[ Source ]

 
Copyright © Twig's Tech Tips
Theme by BloggerThemes & TopWPThemes Sponsored by iBlogtoBlog