title: Django: Search stopped working in 1.10
body: <p>I've been working on an application I originally started in Django 1.7, then ported it over to 1.10, where it stopped working. It will work if I select a District to search by, but only by the District. What I'm hoping is that if all the search terms are left blank, it will return all objects in that pool. It would be great if anyone had some ideas on where this is going wrong, as it doesn't give me errors, just tells me there are no results.</p>
  
  <p>Model:</p>
  
  <pre><code>class PlantingSite(models.Model):
      id_planting_site    = models.IntegerField(null=True, blank=True)
      empty               = models.BooleanField(default=False)
      address             = models.CharField(max_length=256, null=True, blank=True)
      street              = models.CharField(max_length=256, null=True, blank=True)
      coord_lat           = models.CharField(max_length=256, null=True, blank=True)
      coord_long          = models.CharField(max_length=256, null=True, blank=True)
      zipcode             = models.CharField(max_length=256, null=True, blank=True)
      neighborhood        = models.ForeignKey(Neighborhood, null=True)
      district            = models.ForeignKey(District, null=True)
      property_address    = models.CharField(max_length=256, null=True, blank=True)
      property_street     = models.CharField(max_length=256, null=True, blank=True)
      property_zipcode    = models.CharField(max_length=256, null=True, blank=True)
      property_owner      = models.ForeignKey(Contact, related_name='planting_sites_owned_by_contact', null=True)
      contact             = models.ForeignKey(Contact, related_name='planting_sites_cared_for_by_contact', null=True)
      notes               = models.TextField(null=True, blank=True)
      basin_type          = models.ForeignKey(BasinType, related_name='planting_sites_with_basin_type', null=True)
      overhead_utility    = models.ManyToManyField(OverheadUtility, related_name='planting_sites_with_overhead_utility', blank=True)
      hardscape_damage    = models.ManyToManyField(HardscapeDamage, related_name='planting_sites_with_hardscape_damage', blank=True)
      aspect              = models.ForeignKey(Aspect, null=True)
      sequence            = models.IntegerField(null=True, blank=True)
      side                = models.CharField(max_length=256, null=True, blank=True)
      size                = models.CharField(max_length=256, null=True, blank=True)
      created_by          = models.ForeignKey(User, related_name='planting_sites_created', null=True)
      created_at          = models.DateTimeField(default=timezone.now)
      last_edited         = models.DateTimeField(null=True, blank=True)
  
      def __unicode__(self):
          return unicode(self.id_planting_site)
  
      class Meta:
          ordering = ['-created_at']
  </code></pre>
  
  <p>My View:</p>
  
  <pre><code>def uf_search(request):
      if request.POST:
          search_sent = True
          # SEARCH PLANTING SITES
          if request.POST.get('search_type_id') == "1":
              planting_site_search = True
              if request.POST.get('address_range'):
                  if request.POST.get('address_start') and request.POST.get('address_end'):
                      address_start       = request.POST.get('address_start')
                      address_end         = request.POST.get('address_end')
                      r_address           = Q(address__range=[address_start, address_end])
                  else:
                      r_address           = Q(address__isnull=False) | Q(address__isnull=True)
              elif request.POST.get('address_exact'):
                  if request.POST.get('address'):
                      address             = request.POST.get('address')
                      r_address           = Q(address__icontains=address)
              else:
                  r_address               = Q(address__isnull=False) | Q(address__isnull=True)
  
              planting_site_fields = {
                  'street': request.POST.get('street'),
                  'zipcode': request.POST.get('zipcode'),
                  }
  
              r_objects = Q()
  
              if request.POST.get('neighborhood_id'):
                  r_neighborhood = Q(neighborhood__id_neighborhood=request.POST.get('neighborhood_id'))
              else:
                  r_neighborhood = Q(neighborhood__id_neighborhood__isnull=False) |  Q(neighborhood__id_neighborhood__isnull=True)
  
              if request.POST.get('district_id'):
                  r_district = Q(district__id_district=request.POST.get('district_id'))
              else:
                  r_district = Q(district__id_district=False) |  Q(district__id_district=True)
  
              for field, value in planting_site_fields.iteritems():
                  if value:
                      r_objects = Q(**{field+'__icontains': value})
  
              if request.POST.get('empty_planting_sites'):
                  search_results = PlantingSite.objects.values('id', 'id_planting_site', 'address', 'street', 'zipcode', 'neighborhood__name', 'district__name', 'empty').filter(r_address, r_objects, r_neighborhood, r_district, empty=True)
              else:
                  search_results = PlantingSite.objects.values('id', 'id_planting_site', 'address', 'street', 'zipcode', 'neighborhood__name', 'district__name', 'empty').filter(r_address, r_objects, r_neighborhood, r_district)
  
              request.session['search_results'] = list(search_results)
              neighborhood_list = Neighborhood.objects.all()
              district_list = District.objects.all()
              species_list = Species.objects.all()
              condition_list = TreeCondition.objects.all()
              args = {'search_sent': search_sent, 'planting_site_search': planting_site_search, 'search_results': search_results, 'neighborhood_list': neighborhood_list, 
                  'district_list': district_list, 'species_list': species_list, 'condition_list': condition_list}
              args.update(csrf(request))
              return render(request, 'uf_search.html', args)
  </code></pre>
  
  <p>Template:</p>
  
  <pre><code>&lt;form action="/forest/search/" method="post"&gt;
      {% csrf_token %}
      &lt;input type="hidden" name="search_type_id" id="search_type_id" value="1"&gt;
      &lt;p&gt;
          &lt;div class="row"&gt;
              &lt;div class="col-sm-4"&gt;
                  Address:
              &lt;/div&gt;
              &lt;div class="col-sm-4"&gt;
                  Exact: &lt;input type="checkbox" name="address_exact" id="address_exact" /&gt; 
              &lt;/div&gt;
              &lt;div class="col-sm-4"&gt;
                  Range: &lt;input type="checkbox" name="address_range" id="address_range" /&gt; 
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/p&gt;
      &lt;p&gt;
          &lt;div class="row"&gt;
              &lt;div class="col-sm-4"&gt;
                  Range:
              &lt;/div&gt;
              &lt;div class="col-sm-8"&gt;
                  &lt;input type="text" id="address_start" name="address_start" /&gt; to &lt;input type="text" id="address_end" name="address_end" /&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/p&gt;
      &lt;p&gt;
          &lt;div class="row"&gt;
              &lt;div class="col-sm-4"&gt;
                  Exact:
              &lt;/div&gt;
              &lt;div class="col-sm-8"&gt;
                  &lt;input type="text" id="address" name="address" /&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/p&gt;
      &lt;p&gt;
          &lt;div class="row"&gt;
              &lt;div class="col-sm-4"&gt;
                  Street:
              &lt;/div&gt;
              &lt;div class="col-sm-8"&gt;
                  &lt;input type="text" id="street" name="street" /&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/p&gt;
      &lt;p&gt;
          &lt;div class="row"&gt;
              &lt;div class="col-sm-4"&gt;
                  Zipcode:
              &lt;/div&gt;
              &lt;div class="col-sm-8"&gt;
                  &lt;input type="text" id="zipcode" name="zipcode" /&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/p&gt;
      &lt;p&gt;
          &lt;div class="row"&gt;
              &lt;div class="col-sm-4"&gt;
                  Neighborhood:
              &lt;/div&gt;
              &lt;div class="col-sm-8"&gt;
                  &lt;select name="neighborhood_id" id="neighborhood_id"&gt;
                      &lt;option value=""&gt;Select:&lt;/option&gt;
                      {% for neighborhood in neighborhood_list %}
                          &lt;option value="{{neighborhood.id_neighborhood}}"&gt;{{neighborhood.name}}&lt;/option&gt;
                      {% endfor %}
                  &lt;/select&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/p&gt;
      &lt;p&gt;
          &lt;div class="row"&gt;
              &lt;div class="col-sm-4"&gt;
                  District:
              &lt;/div&gt;
              &lt;div class="col-sm-8"&gt;
                  &lt;select name="district_id" id="district_id"&gt;
                      &lt;option value=""&gt;Select:&lt;/option&gt;
                      {% for district in district_list %}
                          &lt;option value="{{district.id_district}}"&gt;{{district.name}}&lt;/option&gt;
                      {% endfor %}
                  &lt;/select&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/p&gt;
      &lt;p&gt;
          &lt;div class="row"&gt;
              &lt;div class="col-sm-4"&gt;
              &lt;/div&gt;
              &lt;div class="col-sm-8"&gt;
                  &lt;input type="checkbox" name="empty_planting_sites" id="empty_planting_sites"&gt; 
                  Show Empty Planting Sites Only
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/p&gt;
      &lt;input type="submit" name="submit" id="submit" value="Search" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Any ideas? Is it something that was dropped in the newest version?</p>