Following this question, I'd like to know if there any difference in writing
.filter(league_pk__in=[1,2,3])
and
.filter(league=[1,2,3])
I have tried both and they seem to return the same results in my code but nowhere in the documentation does it say that they're the same thing (as with __exact
).
Can I safely assume the two forms are equal? Where is it documented?
Without knowing what the relation is defined on your models, we can't say for sure. What I can give you is a way to check the query, that will tell you for sure if they are equivalent or not:
print your_qs.filter(league_pk__in=[1,2,3]).query
print your_qs.filter(league=[1,2,3]).query
And look at the sql generated to see what's actually going on at the db level.
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