title: How do i use filter to filter multiple radio buttons in django template in Django
body: <p>How do i use filter to filter multiple radio buttons in django template in Django...I want a situation where when you select multiple buttons it filters the cars based on how many cars you have selected.</p>
  <p>This is my views.py</p>
  <p>How do i use filter to filter multiple radio buttons in django template in Django...I want a situation where when you select multiple buttons it filters the cars based on how many cars you have selected.</p>
  <p>def new_cars(request): if request.method == &quot;POST&quot;: car_brand_label = request.POST.getlist('car_brand_label') if not car_brand_label : car_brand_label = &quot;&quot;</p>
  <pre><code>for car_brand_label_iter in car_brand_label:
      #  print(car_brand_label_iter)
       image_new_car = Image.objects.filter(car__condition = 'BRAND NEW',car__brand__icontains = car_brand_label_iter )
       new_car = Car.objects.filter(condition = 'BRAND NEW',brand__icontains= car_brand_label_iter)
  
  
  
  new_car_label = Car.objects.filter(condition = 'BRAND NEW')
  new_cars_list = zip(new_car,image_new_car )   
  
  
  
  
  
  new_car_label = Car.objects.filter(condition = 'BRAND NEW')
  new_cars_list = zip(new_car,image_new_car )
  
  
  # new_cars_label = zip(new_car,image_new_car )
  
  
  context = {
      'new_cars_list' : new_cars_list,
      'new_cars_label' : new_car_label
      }
  return render(request, 'frontend/new_cars.html', context)
  </code></pre>
  <p>else:</p>
  <pre><code>image_new_car = Image.objects.filter(car__condition = 'BRAND NEW')
  new_car = Car.objects.filter(condition = 'BRAND NEW')
  
  new_cars_list = zip(new_car,image_new_car )
  new_cars_label = zip(new_car,image_new_car )
  
  context = {
      'new_cars_list' : new_cars_list,
      'new_cars_label' : new_car
      }
  return render(request, 'frontend/new_cars.html', context)
  </code></pre>
  <p>and this is my template.</p>
  
      
  <pre><code>    &lt;a href=&quot;{% url 'new_cars' %}&quot;&gt;
          &lt;h4&gt;Brand New Cars&lt;/h4&gt;&lt;/a&gt;
  
      {% for new_car,image_new_car in new_cars_list %}
    &lt;div id=&quot;&quot; class=&quot;col-sm-6 col-md-4 col-lg-3&quot;&gt;
      &lt;figure&gt;
          &lt;a href=&quot;{% url 'listingview' new_car.brand  new_car.id%}&quot;&gt;
              {% load static %} &lt;img id=&quot;car-img-border&quot; src=&quot; /media/{{image_new_car.image_name}}&quot; alt=&quot;Lights&quot; style=&quot;width:70%&quot;&gt;
          &lt;!-- &lt;figcaption&gt;{{data.car.brand}}&lt;/figcaption&gt;
          &lt;figcaption&gt;{{data.car.model}}&lt;/figcaption&gt;
          &lt;figcaption&gt;{{data.car.year}}&lt;/figcaption&gt; --&gt;
  
      &lt;div style=&quot;display:inline-flex;color: rgb(146, 180, 201); &quot;&gt;
          &lt;h6&gt;{{new_car.year}}&lt;/h6&gt;
          &lt;h6 style=&quot;margin-left: 5px;margin-right: 5px;&quot;&gt;{{new_car.brand}}&lt;/h6&gt;
          &lt;h6&gt;{{new_car.model}}&lt;/h6&gt;
      &lt;/div&gt;    
          &lt;/a&gt;
      &lt;/figure&gt;
    &lt;/div&gt;
    {% endfor %}
  &lt;/div&gt;
  </code></pre>