New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CharFilter(widget=CSVWidget) no longer works in 1.x #727
Comments
Try something like:
|
I spent some time myself running into this problem, and I think @carltongibson solution definitely helps some issues for me. I was attempting to do something like: class TestListFilter(Filter):
field_class = forms.CharField
def filter(self, qs, value):
actual_filter = fields.Lookup(value, 'in')
from pprint import pprint
pprint(value)
pprint(actual_filter)
return qs
class BaseModelFilter(filters.FilterSet):
id__in = TestListFilter(name='id', lookup_expr='in', widget=widgets.CSVWidget) Using DRF & a url of: However it seems as though using Printing the value of the filter results in Per the recommendation provided I switch things up to: class UUIDInFilter(filters.BaseInFilter, filters.UUIDFilter):
pass
class BaseModelFilter(filters.FilterSet):
id = UUIDInFilter(name='id', lookup_expr='in') And then I was able to use to get the expected results. The "List as string" thing kind of seems like a bug or at least some doc changes maybe? I'm pretty unfamiliar with how the underlying functionality works though. Maybe it's just use error =) |
The easiest way to get the correct field behavior is to mixin the |
I was using CSVWidget with a CharFilter in the pre 1.x days, but I'm upgrading and that combination no longer works. I can't find any docs or recommendations on what to switch to. I want to accept a single value or multiple values separated by commas
The text was updated successfully, but these errors were encountered: