Answer the question
In order to leave comments, you need to log in
How to get value from select(ChoiceField)?
How to take value (value) from select?
the form
class sortirovkaForm(forms.Form):
prise_spisok = [
('no', 'не важно'),
('little', 'сначала дешёвые'),
('big', 'сначала дорогие'),
]
categori = forms.ChoiceField(label= '', initial= 'цена', choices= prise_spisok)
def indexDef(request):
catalog = shablonModel.objects.filter(proverka = True)
if request.method == "POST":
form = sortirovkaForm(request.POST)
if form.is_valid():
# меняю значения из формы
menau = form.save(commit = False)
<b>if menau.categori == 'little':
catalog = catalog.order_by('-price_box')</b>
return HttpResponseRedirect('/rusa/')
else:
return Http404('Ошибка =( Попробуйте повторить позже.')
else:
form = sortirovkaForm()
catalog[:18]
return render(request, "user/index.html", {'catalog' : catalog, 'form_prise' : form, })
Answer the question
In order to leave comments, you need to log in
If you really want perversions, then
class ФормаСортировки(forms.Form):
список_цен = [
('no', 'не важно'),
('little', 'сначала дешёвые'),
('big', 'сначала дорогие'),
]
категория = forms.ChoiceField(label= '', initial= 'цена', choices= список_цен)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question