Closed xentry closed 10 years ago
According to: https://docs.djangoproject.com/en/dev/ref/models/querysets/#when-querysets-are-evaluated: "Don’t use len() on QuerySets if all you want to do is determine the number of records in the set. It’s much more efficient to handle a count at the database level, using SQL’s SELECT COUNT(*), and Django provides a count() method for precisely this reason."
I have never seen "TypeError: count() takes exactly one argument (0 given)" error. If you experience it then please describe how to reproduce it.
You are absolutely right, it's my mistake.
2014-08-10 13:10 GMT+04:00 Maciej Wiśniowski notifications@github.com:
According to: https://docs.djangoproject.com/en/dev/ref/models/querysets/#when-querysets-are-evaluated: "Don’t use len() on QuerySets if all you want to do is determine the number of records in the set. It’s much more efficient to handle a count at the database level, using SQL’s SELECT COUNT(*), and Django provides a count() method for precisely this reason."
I have never seen "TypeError: count() takes exactly one argument (0 given)" error. If you experience it then please describe how to reproduce it.
— Reply to this email directly or view it on GitHub https://github.com/diefenbach/django-lfs/issues/154#issuecomment-51709878 .
Could anybody explain the reason for [5a3e332] changeset ? I mean "use count instead of len" in the following lines:
@@ -31,7 +31,7 @@ Q(sub_type__in=(STANDARD_PRODUCT, PRODUCT_WITH_VARIANTS, VARIANT)) temp = Product.objects.filter(query)
and
@@ -67,9 +67,7 @@ if sorting: products = products.order_by(sorting)
As i remember count() just return the number of times x appears in the list, and it will be cause for "TypeError: count() takes exactly one argument (0 given)" error.