title: Implement search by two forms django
body: <p>I want to implement search by two parameters form:
  <strong>home.html</strong></p>
  
  <pre><code>&lt;form action="{% url 'search_results' %}" method="get"&gt;
      &lt;input name="q" type="text" placeholder="Search..."&gt;
      &lt;select name="q2" class="form-control" id="exampleFormControlSelect1"&gt;
          &lt;option&gt;All locations&lt;/option&gt;
          &lt;option&gt;RU&lt;/option&gt;
          &lt;option&gt;Ukraine&lt;/option&gt;
          &lt;option&gt;USA&lt;/option&gt;
      &lt;/select&gt;
      &lt;button&gt; Search &lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>When I click to "search" it's OK (I go to <a href="http://127.0.0.1:8001/search/?q=mos&amp;q2=RU" rel="nofollow noreferrer">http://127.0.0.1:8001/search/?q=mos&amp;q2=RU</a>)
  But when I click "next", I receive </p>
  
  <blockquote>
    <p><a href="http://127.0.0.1:8001/search/?city=2&amp;q=mos&amp;q2=" rel="nofollow noreferrer">http://127.0.0.1:8001/search/?city=2&amp;q=mos&amp;q2=</a></p>
  </blockquote>
  
  <p><strong>but I need</strong></p>
  
  <blockquote>
    <p><a href="http://127.0.0.1:8001/search/?city=2&amp;q=mos&amp;q2=RU" rel="nofollow noreferrer">http://127.0.0.1:8001/search/?city=2&amp;q=mos&amp;q2=RU</a></p>
  </blockquote>
  
  <p><strong>How can I fix this?</strong></p>
  
  <pre><code>&lt;a href="/search?city={{ page_obj.next_page_number }}&amp;q={{ query }}&amp;q2= {{query}}"&gt;next&lt;/a&gt;
  </code></pre>
  
  <p>Full code: <strong>search_results.html</strong></p>
  
  <pre><code>&lt;h1&gt;Search Results&lt;/h1&gt;
  
  &lt;ul&gt;
    {% for city in object_list %}
      &lt;li&gt;
        {{ city.name }}, {{ city.state }}
      &lt;/li&gt;
    {% endfor %}
  &lt;/ul&gt;
  
  &lt;div class="pagination"&gt;
      &lt;span class="page-links"&gt;
          {% if page_obj.has_previous %}
              &lt;a href="/search?city={{ page_obj.previous_page_number }}&amp;q={{ query }}"&gt;previous&lt;/a&gt;
  
          {% endif %}
              &lt;span class="page-current"&gt;
                  Page {{ page_obj.number }} of {{ page_obj.paginator.num_pages }}.
              &lt;/span&gt;
          {% if page_obj.has_next %}
              &lt;a href="/search?city={{ page_obj.next_page_number }}&amp;q={{ query }}&amp;q2= {{query}}"&gt;next&lt;/a&gt;
          {% endif %}
      &lt;/span&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>views.py</strong></p>
  
  <pre><code>from django.shortcuts import render
  from django.views.generic import TemplateView, ListView
  from .models import City
  from django.db.models import Q
  from django.shortcuts import render, get_object_or_404
  
  
  class HomePageView(ListView):
      model = City
      template_name = 'cities/home.html'
      paginate_by = 3
      page_kwarg = 'city'
  
  def city_detail(request, pk):
      city = get_object_or_404(City, pk=pk)
      return render(request, 'cities/city_detail.html', {'city': city})
  
  
  class SearchResultsView(ListView):
      model = City
      template_name = 'cities/search_results.html'
      paginate_by = 3
      page_kwarg = 'city'
  
      def get_context_data(self, **kwargs):
          context = super().get_context_data(**kwargs)
          context['query'] = self.request.GET.get('q')
          return context
  
      def get_queryset(self): # new
          query = self.request.GET.get('q')
          query2 = self.request.GET.get('q2')
          print("AAAAAAAAAAAAAAAAAAAAA", query2, type(query2))
          object_list = City.objects.filter(
              (Q(name__icontains=query) | Q(state__icontains=query)) &amp; Q(category=query2)
          )
          return object_list
  </code></pre>
  
  <p><strong>models.py</strong></p>
  
  <pre><code>from django.db import models
  
  class City(models.Model):
      name = models.CharField(max_length=255)
      state = models.CharField(max_length=255)
      COUNTRY = (
          ('RU', 'Russia'),
          ('UKR', 'Ukraine'),
          ('US', 'USA'),
      )
      category = models.CharField(max_length=100, choices=COUNTRY, default='RU')
  
      class Meta:
        verbose_name_plural = "cities"
  
      def __str__(self):
          return self.name
  </code></pre>