Created
November 19, 2021 13:31
-
-
Save BiTree/b0bea7b9c91e04b6a699608f527dea58 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
A B | |
b_kf B表的外键 is_admin bool | |
age int | |
""" | |
qs = A.objects.filter(age__gte=13).filter(b_fk__isnull=False).filter(b_fk__is_admin=True) #空的queryset | |
qs = A.objects.filter(age__gte=13).exclude(b_fk__isnull=True).filter(b_fk__is_admin=True) #查到了正确的queryset |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment