B
B
Boldy2015-01-03 21:32:30
Django
Boldy, 2015-01-03 21:32:30

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

1 answer(s)
Y
Yuri Shikanov, 2015-01-03
@Boldy

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 question

Ask a Question

731 491 924 answers to any question