1π
β
It appears as though you are just trying to get a list of products matching an existing list, so you can use __in
, you can then make this a list too if you really need a list of querysets for some reason
products = Product.objects.filter(company_id__in=ids)
odd_list = [products]
The added advantage of this is that this performs a single query to your database instead of n
queries, it also avoids the need to manually resolve the queryset so that it stays a lazy query and allows you to extend upon this query with further filters as necessary.
π€Sayse
Source:stackexchange.com