I have a model field price and using class base views, I have added 'django_filters' to settings as well, this is what I have in my project:
model.py
class Product(models.Model):
price = models.IntegerField(default=0)
setting.py
'django_filters',
views.py
class ProductListView(generic.ListView):
template_name = "product/product_list.html"
queryset = Product.objects.all()
filter_set = ProductFilter
filters.py
class ProductFilter(django_filters.FilterSet):
min_price = django_filters.NumberFilter(field_name="price",
lookup_expr='gt',widget=RangeWidget(attrs={'placeholder': 'min_price'}))
max_price = django_filters.NumberFilter(field_name="price",
lookup_expr='lt',widget=RangeWidget(attrs={'placeholder': 'max_price'}))
class Meta:
model = Product
fields = { 'min_price', 'max_price'
}
everything is working perfectly when using price only in fields without 'min_price', 'max_price',
but what I want is to have min_price and max_price show in my placeholder. When I run the code above, I get this error: "TypeError: 'Meta.fields' must not contain non-model field names: min_price, max_price"