Created
June 24, 2015 09:51
-
-
Save zoidyzoidzoid/9ea0e4feb62a45acffee 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
import django_filters | |
class CommaSeparatedValueFilter(django_filters.CharFilter): | |
"""Accept comma separated string as value and convert it to list. | |
It's useful for __in lookups. | |
""" | |
def filter(self, qs, value): | |
if value: | |
value = value.split(',') | |
return super(CommaSeparatedValueFilter, self).filter(qs, value) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment