From 8cc36e5acb6456b0b181e37eb21726918af5f2a1 Mon Sep 17 00:00:00 2001
From: Thomas Hunger <teh@playfire.com>
Date: Mon, 27 Sep 2010 16:16:21 +0100
Subject: [PATCH] Handle EmptyResultSet exception in paginator.
---
packages/django/core/paginator.py | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/packages/django/core/paginator.py b/packages/django/core/paginator.py
index 495cdf2..544ba87 100644
a
|
b
|
|
1 | 1 | from math import ceil |
2 | 2 | |
| 3 | from django.db.models.sql.datastructures import EmptyResultSet |
| 4 | |
3 | 5 | class InvalidPage(Exception): |
4 | 6 | pass |
5 | 7 | |
… |
… |
class Paginator(object):
|
51 | 53 | # TypeError if object_list.count() requires arguments |
52 | 54 | # (i.e. is of type list). |
53 | 55 | self._count = len(self.object_list) |
| 56 | except EmptyResultSet: |
| 57 | self._count = 0 |
| 58 | |
54 | 59 | return self._count |
55 | 60 | count = property(_get_count) |
56 | 61 | |