Volatil3
Volatil3

Reputation: 14978

How to use IN query in Django ORM?

How do I run the Where IN query in Django ORM and iterate it? The following returns nothing:

user_ids = Wallet.objects.filter(customer_id=[sender_id,reciever_id])
print(user_ids)

Upvotes: 0

Views: 22

Answers (1)

JPG
JPG

Reputation: 88459

You can use in--(doc) lookup as

user_ids = Wallet.objects.filter(customer_id__in=[sender_id,reciever_id])

Upvotes: 2

Related Questions