Created
February 23, 2016 00:27
-
-
Save sobelk/b8b0d29f4e051fafda86 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
from django.db.models import Q | |
def composite_in(columns, tuples): | |
return reduce(Q.__or__, [Q(**dict(zip(columns, t))) for t in tuples]) | |
# | |
# MyModel.objects.filter(composite_in( | |
# ('col1', 'col2'), | |
# [(1,2), (1,3), (2,3)])) | |
# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment