V
V
vaaadimermolin2022-01-17 09:36:57
Django
vaaadimermolin, 2022-01-17 09:36:57

Pass value from template to view?

There is a template and it contains select

<h1>Наименование автомобиля</h1>
    <select name="pets" id="pet-select">
        <option value="">Выберите модель авто</option>
        {% for j in num_categoryyy %}
            <option>{{ j }}</option>
        {% endfor %}
    </select>


I would like to pass the selected value to views.py
def index(request):
if 'В397ВУ09 Газель NEXT' == val1.Наименование:


Instead of V397VU09 Gazelle NEXT, you need to select a value from the template, is it possible to do this or are there any other options?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dr. Bacon, 2022-01-17
@vaaadimermolin

The value lies in or GET, depending on the method. But it's better to use forms. request.POST['pets']

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question