I want to pass a queryset which involves counting rows to a function without calling the database right away. For example, the following queryset is lazy and does not access the database until it is evaluated:
queryset = MyModel.objects.all()
I know from Django docs that len()
forces the evaluation but what about count()
? Does this hit the database right away?
queryset = MyModel.objects.all().count()
EDIT: I clarified my question