title: How to do product sorting when we search for certain product in Django?
body: <p>views.py:-</p>
  
  <pre><code>def search(request):
  global pro
  global products
  if not request.GET.get('price_filter') == '1' or request.GET.get('price_filter') == '2':
      q = request.GET.get("q")
      products = Product.objects.filter(active=True, name__icontains=q)
      categories = Category.objects.filter(active=True)
      brands = Brand.objects.filter(active=True)
      context = {"products": products,
                 "categories": categories,
                  "brands": brands,
                  "title": q + " - search"}
      return render(request, "shop/home.html", context)
  pro = products
  
  if request.GET.get('price_filter') == '1':
      products = pro.order_by('price')
      categories = Category.objects.filter(active=True)
      brands = Brand.objects.filter(active=True)
      context = {"products": products,
                 "categories": categories,
                 "brands": brands}
      return render(request, "shop/home.html", context)
  
  elif request.GET.get('price_filter') == '2':
      products = pro.order_by('-price')
      categories = Category.objects.filter(active=True)
      brands = Brand.objects.filter(active=True)
      context = {"products": products,
                 "categories": categories,
                 "brands": brands}
      return render(request, "shop/home.html", context)
  </code></pre>
  
  <p>In HTML:-</p>
  
  <pre><code>&lt;form method='get' action='#' style="margin-top:-20px; margin-left: 8px;"&gt;
          &lt;input class="btn btn-outline-dark" type="checkbox" value="1" name="price_filter"/&gt;Low to High
  
          &lt;input class="btn btn-outline-dark" type="checkbox" value="2" name="price_filter"/&gt;High to Low
          &lt;button class="btn" type="submit" value="Sort"&gt;Sort&lt;/button&gt;
      &lt;/form&gt;
  </code></pre>
  
  <p>Using that search we I am able to sort low to high, but when I choose High to Low, it shows certain <strong>Error</strong>:-</p>
  
  <pre><code>Cannot use None as a query value
  </code></pre>
  
  <p><strong>I know this is not the right method to do this, but can please help me out with this, or guide me with the correct way to do sorting.</strong></p>