-
-
Save dmarchuk/675a08fc99299daa5ad47cfadff33793 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