Created
December 14, 2015 04:10
-
-
Save ncole458/69cfc4a26141d9ce55eb 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
""" | |
Django REST Framework filtering by comma (used with Ember.js). | |
Change from the standard ?var=1&var=2 etc. | |
""" | |
# GET querystring i.e. ?var=1,2,4,6 | |
get_my_var = self.request.query_params.get('var', None) | |
if get_my_var: | |
my_var = get_my_var.split(',') | |
else: | |
my_var = None | |
# Filter using standard __in | |
queryset = queryset.filter(my_field__in=my_var) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment