Hockey127 Hockey127 - 1 month ago 19
Python Question

Force evaluate a lazy query

Is there a way to evaluate the following expression?

instances = Catalog.objects.filter(q)


I am trying to profile it, but since it is lazy, it won't actually do the evaluation until it returns it. I was thinking
list(instances
), is there anything else?

Answer

Here are all the ways to evaluate a lazy queryset. Using list is one of them:

https://docs.djangoproject.com/en/dev/ref/models/querysets/#when-querysets-are-evaluated

Comments