Created
January 12, 2018 02:57
-
-
Save mgalgs/7fa53d787d30bdeff87a661d7d1188a3 to your computer and use it in GitHub Desktop.
django QuerySet.__or__
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
In [27]: qs1 = User.objects.filter(pk__in=[1, 2]) | |
In [28]: qs2 = User.objects.filter(pk__in=[2, 5]) | |
In [29]: qs3 = qs1 | qs2 | |
In [30]: print qs3.query | |
SELECT "auth_user"."id", "auth_user"."password", "auth_user"."last_login", "auth_user"."is_superuser", "auth_user"."username", "auth_user"."first_name", "auth_user"."last_name", "auth_user"."email", "auth_user"."is_staff", "auth_user"."is_active", "auth_user"."date_joined" FROM "auth_user" WHERE ("auth_user"."id" IN (1, 2) OR "auth_user"."id" IN (2, 5)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment