django/django — pull request #1467 by mattr555 (2013-08-12 02:38:08+00:00)
Title: Fixed bug in paginator when QuerySet is generated with objects.extra()

The paginator relies on the `count()` method on a QuerySet. When a QuerySet is generated with a call to `objects.extra()`, however, the `count()` method is unavailable. It will return with a `DatabaseError: no such column 'foo'`. The other viable option is to take the length of the list of objects in the QuerySet. This is already implemented when the `count()` method can't be accessed for other reasons, so the only thing to do is add `DatabaseError` to the except clause.