Ticket #14348: 0001-Handle-EmptyResultSet-exception-in-paginator.patch

File 0001-Handle-EmptyResultSet-exception-in-paginator.patch, 1014 bytes (added by teh, 14 years ago)
  • packages/django/core/paginator.py

    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  
    11from math import ceil
    22
     3from django.db.models.sql.datastructures import EmptyResultSet
     4
    35class InvalidPage(Exception):
    46    pass
    57
    class Paginator(object):  
    5153                # TypeError if object_list.count() requires arguments
    5254                # (i.e. is of type list).
    5355                self._count = len(self.object_list)
     56            except EmptyResultSet:
     57                self._count = 0
     58
    5459        return self._count
    5560    count = property(_get_count)
    5661
Back to Top