title: Pagination with ListView django
body: <p>I want to create app with search and pagination. Pagination didn't work with ListView.</p>
  
  <p>When I click on the link "next" I am moving from start page <a href="http://127.0.0.1:8001/" rel="nofollow noreferrer">http://127.0.0.1:8001/</a> --->  to the  <a href="http://127.0.0.1:8001/?city=2" rel="nofollow noreferrer">http://127.0.0.1:8001/?city=2</a> but elements of the list did not change. </p>
  
  <p>And next click to the "next" link did not changes the url ( <a href="http://127.0.0.1:8001/?city=2" rel="nofollow noreferrer">http://127.0.0.1:8001/?city=2</a> -->  <a href="http://127.0.0.1:8001/?city=2" rel="nofollow noreferrer">http://127.0.0.1:8001/?city=2</a>).</p>
  
  <p><strong>Could you help me to find error?</strong> 
  I think that error in *.html file, but can't find it</p>
  
  <p>My code:
  <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)
  
      class Meta:
        verbose_name_plural = "cities"
  
      def __str__(self):
          return self.name
  </code></pre>
  
  <p><strong>urls.py</strong></p>
  
  <pre><code># cities/urls.py
  from django.urls import path
  from . import views
  from .views import HomePageView, SearchResultsView
  
  urlpatterns = [
      path('search/', SearchResultsView.as_view(), name='search_results'),
      path('', HomePageView.as_view(), name='home'),
      path('city/&lt;int:pk&gt;/', views.city_detail, name='city_detail'),
  ]
  </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
  
  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'
  
      def get_queryset(self): # new
          query = self.request.GET.get('q')
          object_list = City.objects.filter(
              Q(name__icontains=query) | Q(state__icontains=query)
          )
          return object_list
  </code></pre>
  
  <p><strong>home.html</strong></p>
  
  <pre><code>&lt;!-- templates/home.html --&gt;
  &lt;h1&gt;HomePage&lt;/h1&gt;
  
  &lt;form action="{% url 'search_results' %}" method="get"&gt;
    &lt;input name="q" type="text" placeholder="Search..."&gt;
  &lt;/form&gt;
  
  &lt;ul&gt;
    {% for city in object_list %}
      &lt;li&gt;
        &lt;h1&gt;&lt;a href="{% url 'city_detail' pk=city.pk %}"&gt;{{ city.name }}&lt;/a&gt;&lt;/h1&gt;
      &lt;/li&gt;
    {% endfor %}
  &lt;/ul&gt;
  
  
  {{page_obj}}
  
  &lt;div class="pagination"&gt;
      &lt;span class="page-links"&gt;
          {% if page_obj.has_previous %}
              &lt;a href="/?city={{ page_obj.previous_page_number }}"&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="/?city={{ page_obj.next_page_number }}"&gt;next&lt;/a&gt;
          {% endif %}
      &lt;/span&gt;
  &lt;/div&gt;
  </code></pre>