When I filter I need to request.GET.value to be selected

I have to filter some data so I need to use a select field but when I submit the form the result disappears. I have to selected the value that is choice previous

` <label class="text-secondary">Discount Type</label>
  <select  name="discount_type" class="form-control" >
   <option  value="" class="text-center" >Select Type</option>
   {% for i in type %}
    <option {% if i.0 == request.GET.status %} selected {% endif %} value="{{ i.0   }}" >{{ i.1 }}
    </option>
    {% endfor %}
 </select>`

Have you tried to create a variable in the context? Here the problem is during the POST you probably don't have the request.GET values anymore

This could be helpful

Django : Maintaining option selected in HTML template

Back to Top