You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I would like to use 2 custom field names when using a RangeFilter. Instead of something like myField_max I would want to use something like myFieldMax. This way I can pass the entire params dictionary request.GET directly into the filter while still conforming to the snake case naming convention my front end uses to call my API. Is this currently possible?
Thanks,
Zach
The text was updated successfully, but these errors were encountered:
#951 also links to the migration guide for v2 when SuffixedMultiWidget was introduced, but to get myFiledMax you’d need to customise MultiValueField more radically.
(If you do come up with something there, let me know.)
Here's the workaround I use. Let's say we want the fields to be called "start" and "end". I've only tested this with DateRange. It still requires setting many classes.
classStartEndDateRangeWidget(DateRangeWidget):
suffixes= ["start", "end"] # Set this to the non-suffixed terms you wishdefsuffixed(self, name, suffix):
returnsuffix# Avoids the name_suffix formatclassStartEndDateTimeRangeField(DateTimeRangeField):
widget=StartEndDateRangeWidgetclassStartEndDateTimeFromToRangeFilter(filters.DateTimeFromToRangeFilter):
field_class=StartEndDateTimeRangeFieldclassFooFilter(FilterSet):
created=StartEndDateTimeFromToRangeFilter(
field_name="related__therefore__we__really__cant__use__multiple__fields__created",
label="Wow so pretty"
)
Hello, I would like to use 2 custom field names when using a
RangeFilter
. Instead of something likemyField_max
I would want to use something likemyFieldMax
. This way I can pass the entire params dictionaryrequest.GET
directly into the filter while still conforming to the snake case naming convention my front end uses to call my API. Is this currently possible?Thanks,
Zach
The text was updated successfully, but these errors were encountered: