Answer the question
In order to leave comments, you need to log in
How to turn a generator into a queryset in django?
For example, there is an object generator:
(x for x in queryset.all() if x.is_defaulter) (is_defaulter is a property, not a field)
How do I create a queryset that contains only the rows that the generator should generate?
Answer the question
In order to leave comments, you need to log in
If I understood the task correctly, then you can get a list of object IDs from the generator and then make a queryset with IN: Model.objects.filter(id__in=ids), where ids is a list of id received from the generator.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question