From: Zygmunt Krynicki Date: Tue, 14 Jun 2011 08:53:42 +0000 (+0200) Subject: Be smarter about missing request object. X-Git-Tag: release-2.0~14 X-Git-Url: https://git.mdrn.pl/django-pagination.git/commitdiff_plain/79b65b1914b1db437200f57df24f76653d0451cc?hp=-c Be smarter about missing request object. The application requires uses to use request context processor. If it is not enabled let's warn the user and explain the situation using ImproperlyConfigured exception rather than cryptic bactrace. --- 79b65b1914b1db437200f57df24f76653d0451cc diff --git a/linaro_django_pagination/templatetags/pagination_tags.py b/linaro_django_pagination/templatetags/pagination_tags.py index 05c44f3..e8331c2 100644 --- a/linaro_django_pagination/templatetags/pagination_tags.py +++ b/linaro_django_pagination/templatetags/pagination_tags.py @@ -144,7 +144,13 @@ class AutoPaginateNode(template.Node): orphans = self.orphans.resolve(context) paginator = Paginator(value, paginate_by, orphans) try: - page_obj = paginator.page(context['request'].page(page_suffix)) + request = context['request'] + except KeyError: + raise ImproperlyConfigured( + "You need to enable 'django.core.context_processors.request'." + " See linaro-django-pagination/README file for TEMPLATE_CONTEXT_PROCESSORS details") + try: + page_obj = paginator.page(request.page(page_suffix)) except InvalidPage: if INVALID_PAGE_RAISES_404: raise Http404('Invalid page requested. If DEBUG were set to ' +