#9041: invalid count result when paired with select_related ---------------------------------------------------+------------------------ Reporter: Mathieu Bouchard <[EMAIL PROTECTED]> | Owner: nobody Status: new | Milestone: Component: Uncategorized | Version: 1.0 Keywords: | Stage: Unreviewed Has_patch: 0 | ---------------------------------------------------+------------------------ When using a select_related, I sometimes get invalid results if the select_related method reject some data because they are not valid. If, for example, I have a model that requires a reference to another object and that reference is, for some reason, None, these entries will be rejected by the select_related.
The problem is that the Paginator object uses the count method to tell the user how many items are found, but when we try to use these items, we only get an empty page. {{{ >>> a = Session.objects.filter(Key__value = "www").select_related() >>> a.count() 29L >>> len(a) 3 }}} {{{ >>> from django.core.paginator import Paginator >>> from metrix2.manager.models import Session >>> q = Session.objects.filter(Key__string = "2PSpuaRIZGNj").select_related() >>> p = Paginator(q, 15) >>> p.count 29L >>> p.num_pages 2 >>> p.page(1).object_list [<Session: xxx>, <Session: yyy>, <Session: zzz>] >>> p.page(2).object_list [] }}} -- Ticket URL: <http://code.djangoproject.com/ticket/9041> Django <http://code.djangoproject.com/> 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 django-updates@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-updates?hl=en -~----------~----~----~----~------~----~------~--~---