I just spent a while chasing my tail because I was passing the results
of get_list_or_404 to the QuerySetPaginator, not realizing that it
returns a list and not a QuerySet object.

When I tried to get the count, it raised the exception: "TypeError:
count() takes exactly one argument (0 given)"

I probably would have realized the stupidity of my error more quickly
if _get_count was making sure that I passed QuerySetPaginator a
QuerySet object and not a list.

Would there be any merit to checking the type of the object_list
parameter? I'm not sure of the ramifications, so I'm just asking, not
necessarily suggesting :)

I see that there is an unreviewed ticket that would obviate a type
check:
http://code.djangoproject.com/ticket/7478

Here's what I saw:

>>> from django.core.paginator import Paginator, QuerySetPaginator
>>> from django.contrib.auth.models import User
>>> from django.shortcuts import get_list_or_404
>>>
>>> ul1 = User.objects.all()
>>> ul2 = get_list_or_404(User.objects.all())
>>>
>>> pp = Paginator(ul1, 2)
>>> pp.count
1
>>> qp = QuerySetPaginator(ul2, 2)
>>> qp.count
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/home2/tbo/webapps/django_wsgi/django/core/paginator.py", line
70, in _get_count
TypeError: count() takes exactly one argument (0 given)


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@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-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to