44👍
✅
From the Migrating to 2.0 guide,
Filter.name
renamed toFilter.field_name
(#792)The filter name has been renamed to
field_name
as a way to disambiguate the filter’s attribute name on its FilterSet class from thefield_name
used for filtering purposes.
So, from django-filter==2.0
onwards, use field_name
instead of name
class GoodsFilter(filters.FilterSet):
pricemin = filters.NumberFilter(field_name="shop_price", lookup_expr='gte')
pricemax = filters.NumberFilter(field_name="shop_price", lookup_expr='lte')
class Meta:
model = Goods
fields = ['pricemin', 'pricemax']
👤JPG
Source:stackexchange.com