BaseInFilter alternate delimiter? #1414
-
Hi, First off, thank you to those working on this awesome module, it's been super helpful! My issue is mostly just a question/idea for the BaseInFilter class. Is it currently possible to change the delimiter of the BaseInFilter? I see that the class itself is a child class of the BaseCSVFilter, so I'm guessing it's not. Is there any support or plans to support using a different delimiter and/or escaping the comma? Thank you for your time! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
I'm wondering the same thing. Using The following don't work (not that I really expected them to):
|
Beta Was this translation helpful? Give feedback.
-
The CSV filters were added for API usage. The previous approach of multiple entries still works, and I’d say go for that.
Either that or you’ll need to adapt the CSV code to your own needs, but it’s not something I’d want to include. |
Beta Was this translation helpful? Give feedback.
-
It is actually possible to achieve this using class ArrayFilter(filters.Filter):
field_class = SimpleArrayField and then something like this: ids = ArrayFilter(
field_name="id",
lookup_expr="in",
base_field=forms.IntegerField(min_value=0),
max_length=50,
delimiter=",", # <-- here
required=True,
help_text="Multiple values may be separated by commas. Enter 50 at most.",
) You can even specify |
Beta Was this translation helpful? Give feedback.
The CSV filters were added for API usage. The previous approach of multiple entries still works, and I’d say go for that.
?a=1&a=2&a=3
Either that or you’ll need to adapt the CSV code to your own needs, but it’s not something I’d want to include.