Answer the question
In order to leave comments, you need to log in
How to filter goods by seller (seller is a user in a certain group)?
How to add a field to the filtering form where you can select a seller and only the goods of this seller will remain on the site?
filter form
class FilterWare(forms.Form):
max_price = forms.DecimalField(max_digits = 7, decimal_places=0, required=False)
...
def shop_ware(request):
ware = Ware.objects.all()
form = FilterWare(request.GET)
if form.is_valid():
if form.cleaned_data["max_price"]:
ware = ware.filter(prise__gte=form.cleaned_data["max_price"])
context ={
'ware': ware,
'form': form
}
return render(request, 'index.html', context)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question