Skip to content

Instantly share code, notes, and snippets.

@mattdeboard
Created November 22, 2011 15:40
Show Gist options
  • Save mattdeboard/1385957 to your computer and use it in GitHub Desktop.
Save mattdeboard/1385957 to your computer and use it in GitHub Desktop.
Snippet for passing in multiple field names into a single filter call.
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