[Answer]-Django Queries to return a specific set of items

1👍

To get only Product2 and Product4 you can do:

products = [Product.objects.get(name='Product2'), Product.objects.get(name='Product4')]
products = [(product.name, product.name) for product in products]

If this is not quite the answer you were expecting, please specify the criteria you’d like to filter your objects with.

👤piokuc

Leave a comment