title: error when page is refreshed in django
body: <p>I am learning to create a website using django. I have a homepage through which user can select city. The next page shows the list of hotels.It works properly,but when page is refreshed it gives me error</p>
  
  <p>This is my html file for list page.</p>
  
  <pre><code>&lt;link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"&gt;
  
  &lt;!-- jQuery library --&gt;
  &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"&gt;&lt;/script&gt;
  
  &lt;!-- Latest compiled JavaScript --&gt;
  &lt;script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"&gt;&lt;/script&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;
  &lt;link rel="stylesheet" href="//code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css"&gt;
   &lt;script src="//code.jquery.com/jquery-1.10.2.min.js"&gt;&lt;/script&gt;
   &lt;script src="//code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"&gt;&lt;/script&gt;
   &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-backstretch/2.0.4/jquery.backstretch.min.js"&gt;&lt;/script&gt;
  &lt;script  type="text/javascript" src="../js/typeahead/0.11.1/typeahead.bundle.js"&gt;&lt;/script&gt;
  &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.min.js"&gt;&lt;/script&gt;
  
  {% load static %}
  &lt;script src="/static/typeahead.js "&gt;&lt;/script&gt;
  
  
  
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;div &gt;
  &lt;div style="float:left; background-color:#d9d9d9;margin-top:100px;width:30%;height:800px;"&gt;
  &lt;h2 style="text-align:center;"&gt;Filters&lt;/h2&gt;
  &lt;div  style="width:95%; margin-left: 10px; " &gt;
      &lt;form method="post" data-ajax="false" action="{% url 'list' %}"&gt;
       {% csrf_token %}
  
         &lt;div data-role="rangeslider" data-mini="true" style="width:100%"&gt;
      &lt;label for="range-1a"&gt;price:&lt;/label&gt;
      &lt;input name="range-1a" id="range-1a" min="0" max="100" value="0" type="range"&gt;
      &lt;label for="range-1b"&gt;Rangeslider:&lt;/label&gt;
      &lt;input name="range-1b" id="range-1b" min="0" max="100" value="100" type="range"&gt;
    &lt;/div&gt;
    &lt;input type="submit"  value="Submit"&gt;
        &lt;/form&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div style=" float:right;margin-right:30px;margin-top:100px;width:60%;height:80%"&gt;
  
  
  
  {% for hotel in city_list %}
  {% load static %}
  
     &lt;div class="col-md-4" style="width:45%;border:0;position:relative;"&gt;
      &lt;div class="thumbnail" style="height:300px; background-color:black;border:0;border-radius:0;position:relative;box-shadow:0;" &gt;
        &lt;a href="/w3images/lights.jpg" data-ajax="false"&gt;
          &lt;img src="{% static hotel.photo.url %}" style="border:0;height:85%;width:100%;"  &gt;
          &lt;div class="caption"&gt;
            &lt;p style="color:white;"&gt;Name&lt;/p&gt;
          &lt;/div&gt;
        &lt;/a&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  
  
  
  
  
  
  {% endfor %}
  
  &lt;/div&gt;  
  
  
  &lt;/div&gt;
  
  
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>This is my views.py</p>
  
  <pre><code>def homepage(request):
      hotel_list=Hotels.objects.all()
      context={'hotel_list':hotel_list}
      return render(request, 'polls/homepage.html',context)
  
  def wholelist(request):
      hotelvar=request.POST.get('service_type')
      if hotelvar=='Hotels':
  
        city_list=Hotels.objects.filter(city_name__iexact=request.POST.get('searchabc'))
      if not city_list:
          hotel_list=Hotels.objects.all()
          context={'hotel_list':hotel_list}
          return render(request, 'polls/homepage.html',context)
  
      pricemin=200
      pricemax=800
  
      context={'pmin':pricemin,'pmax':pricemax,'city_list':city_list}
      return render(request, 'polls/list.html',context)
  </code></pre>
  
  <p>i get the following error when refreshed
  <code>UnboundLocalError</code> at /polls/wholelist/
  local variable <code>city_list</code> referenced before assignment</p>
  
  <p><code>city_list</code> is being passed from the homepage, but when page is reloaded it not being passed. Is there a way to pass it when page is refreshed?</p>