Answer the question
In order to leave comments, you need to log in
How to get 2 get parameters?
There are 2 forms. 1 - search, 2 filter
1.
<form class="form" action =" {% url 'search' %}" >
<div class="input-group">
<input class="form-control border-right-0 border " type="search" placeholder="Искать товары", name="search">
<span class="input-group-append">
<div class="input-group-text bg-transparent p-0">
</div>
<button class="btn btn-outline-success " type="submit"><i class="fa fa-search"></i></button>
</span>
</div>
</form>
<form class="form for_change_items" method="get" name ="a" >
<div class="form-check p-0 " >
<input class="form-check-input" type="radio" onClick="a.submit()" name="model_or_item" id="model" value="model">
<input class="form-check-input" type="radio" onClick="a.submit()" name="model_or_item" id="item" value="item" >
<a class= "gray_text">{{items.count }} товар (-а, -ов)</a>
<input class="form-check-input" type="radio" name="change_items" onClick="a.submit()" checked id="2_items" value="2_items" >
<input class="form-check-input" type="radio" name="change_items" onClick="a.submit()" id="many_items" value="many_items">
<label {% if model_or_item == 'item' %} style=" opacity:0.7;" {% endif %} class="form-check-label font-weight-bolder" for="model">
<a {% if model_or_item == 'model' %} style=" text-decoration: underline;" {% endif %}>Модель</a>
</label>
<label {% if model_or_item == 'model' %} style=" opacity:0.7;" {% endif %} class="form-check-label font-weight-bolder " for="item">
<a {% if model_or_item == 'item' %} style=" text-decoration: underline;" {% endif %}>Изделие</a>
</label>
</div>
</form>
search = request.GET.get('search')
change_items = request.GET.get('change_items', '2_items')
model_or_item = request.GET.get('model_or_item', 'model')
items = Item.objects.filter(title__icontains = search)
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