#2352: Allow Paginator to Support Non QuerySets
-------------------------------+--------------------------------------------
 Reporter:  [EMAIL PROTECTED]  |       Owner:  adrian                     
     Type:  enhancement        |      Status:  new                        
 Priority:  normal             |   Milestone:                             
Component:  Core framework     |     Version:  SVN                        
 Severity:  normal             |    Keywords:  paginator queryset fetchall
-------------------------------+--------------------------------------------
 I write quite a few Custom SQL queries.  In addition, I like the built in
 paginator package that django provides.  The problem is that paginator.py
 asks for a QuerySet, when all it uses a QuerySet for is to
 query_set.count().  Anyways, my point is... paginator.py should allow for
 queries returned by cursor.fetchall() (and similar).  It's already so
 generic that this tiny patch provides this enhancement:
 
 /django/core/paginator.py
 {{{
 def _get_hits(self):
     if self._hits is None:
         try:
             self._hits = self.query_set.count()
         except:
             self._hits = len(self.query_set)
     return self._hits
 }}}
 
 All I added was the try-except block to default to len(self.query_set) if
 .count() fails

-- 
Ticket URL: <http://code.djangoproject.com/ticket/2352>
Django <http://code.djangoproject.org/>
The web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates
-~----------~----~----~----~------~----~------~--~---

Reply via email to