If I have this queryset:
player = basketball.objects.all()
How can I do a filter where I ask for multiple people? For example: I only want players who's names are "mike" or "charles" to show up. This doesn't seem to work for me:
player.filter(name = 'mike' , 'charles')
Does anyone know the best way to go about this?
You can use __in:
player.filter(name__in=['mike', 'charles'])
Alongside the use of __in, you can also chain multiple filters using the Q object, so objects.filter(q) where q = Q(Q(name="mike")|Q(name="phil")).
Definitely use __in though in this case.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With