Created
November 22, 2011 15:40
-
-
Save mattdeboard/1385957 to your computer and use it in GitHub Desktop.
Snippet for passing in multiple field names into a single filter call.
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
filters = { | |
"name": data.get('name'), | |
"phone": data.get('phone'), | |
"area_code": data.get('area_code'), | |
"location_city": data.get('location_city'), | |
"location_state": data.get('location_state'), | |
"location_ZIP": data.get('location_ZIP'), | |
} | |
sqs = SearchQuerySet().models(Person) | |
for key in filters.keys(): | |
if filters[key]: | |
d = {key: filters[key]} | |
sqs = sqs.filter(**d) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment