title: Django urls and filtering , the right way to achieve this
body: <p>I have a web app to search for cars. On the landing page, I can either enter a keyword and search or go to a link that displays all the data with filters.
  So my URLs,</p>
  
  <pre><code>url(r'^cars/$', search, name='search'), ==&gt; does an elastic search
  url(r'^select/', select, name='select'),==&gt; has links to filter results and pass query set
  </code></pre>
  
  <p>When I enter a keyword (say Audi) and search, the URL becomes localhost:8000/cars/?search=Audi
  and if I click on the link it simply says localhost:8000/select/</p>
  
  <p>Both of these views(search and select) render the same template.
  Now, I want to filter the results or add more criteria. What should be the right approach to do this?
  One of the websites where I got inspired for doing this project simply redirects to 
  /cars?search=Audi and on clicking any link to filter redirects to /cars/Audi/BMW/Sedan 
   Is this possible in Django? </p>
  
  <p>Here is the select view code. I am still learning Django and python, so, please bear with me.</p>
  
  <pre><code>def select(request):
      q1 = request.GET.get('brand')
      q2 = request.GET.get('model')
      q3 = request.GET.get('bodyStyle')
      q4 = request.GET.get('budget[]')
      q5 = request.GET.get('transmission')
      page = request.GET.get('page', 1)
  
      print(q1)
      s1 = request.POST.get('sortBy')
  
  
  
      budarray = request.GET.getlist('budget')
      brandarray = request.GET.getlist('brand')
      modelarray = request.GET.getlist('model')
      bodyarray = request.GET.getlist('bodyStyle')
      transmissionarray = request.GET.getlist('transmission')
  
  
      cars = product_details.objects.all()
      posturl=""
  
  
      if len(brandarray)&gt;0:
                      brandarray=list(dict.fromkeys(brandarray))
                      cars = cars.filter(brand_name__in=brandarray)
  
  
      if len(modelarray)&gt;0:
                      cars = cars.filter(model_name__in=modelarray)
  
      if len(bodyarray)&gt;0:
                      cars = cars.filter(bodystyle__in=bodyarray)
  
      if len(transmissionarray)&gt;0:
                      cars = cars.filter(transmission__in=transmissionarray)
  
  
  
      minp=0
      maxp=0
      denom=""
  
      arraybud =[]
      if len(budarray)&gt;0:
                  for items in budarray:
                      budgetval = GetBudget(items)
  
  
                      minp=int(budgetval[0])
                      maxp=int(budgetval[1])
                      denom=budgetval[2]
                      arraybud.append(minp)
                      arraybud.append(maxp)
  
  
  
      minprice=0
      maxprice=0
  
      if len(budarray)&gt;0:
          minprice=min(arraybud)
          maxprice=max(arraybud)
         if minp&gt;100:
              cars=cars.filter(min_price__gt=minprice).filter(denomination='Crore')
              denom="Crores"
          else:
              denom="Lakhs"
              cars=cars.filter(min_price__gt=minprice,min_price__lt=maxprice).filter(denomination=denom)
  
      sort = GetOrderBy(s1)
  
  
      if sort =="nothing":
          cars = cars.order_by('model_name','min_price')
      else:
          cars = cars.order_by('model_name',sort)
  
      cars = cars.distinct('model_name')
  
      totalResult = cars.count()
      if totalResult &gt;= 50:
          paginator = Paginator(cars, 25)
      else:
          paginator = Paginator(cars, 10)
  
      try:
          cars = paginator.page(page)
      except PageNotAnInteger:
          cars = paginator.page(1)
      except EmptyPage:
          cars = paginator.page(paginator.num_pages)
  
      print(request.get_full_path)
  
      _brands = products.objects.all()
  
      _models= product_models.objects.all()
  
      _bodystyles = product_bodystyle.objects.all()
      posturl = "Y"
  
      hyundaicars = product_details.objects.filter(brand_name='Hyundai').distinct('model_name')
      tatamotors = product_details.objects.filter(brand_name='Tata').distinct('model_name')
      maruticars = product_details.objects.filter(brand_name='Maruti Suzuki').distinct('model_name')
      mahindracars = product_details.objects.filter(brand_name='Mahindra').distinct('model_name')
      hondacars = product_details.objects.filter(brand_name='Honda').distinct('model_name')
  
      for (i, item) in enumerate(budarray):
          if item == "1":
              budarray[i] = "1 - 5 Lakhs"
          if item == "2":
              budarray[i] = "5 - 10 Lakhs"
          if item == "3":
              budarray[i] = "10 - 15 Lakhs"
          if item == "4":
              budarray[i] = "15 - 20 Lakhs"
          if item == "5":
              budarray[i] = "20 - 25 Lakhs"
          if item == "6":
              budarray[i] = "25 - 50 Lakhs"
          if item == "7":
              budarray[i] = "50 - 99 Lakhs"
          if item == "8":
              budarray[i] = "Above 1 Crore"
  
  
      return render(request, 'search/search_results.html', carsdetails) 
  </code></pre>