How to filter price range for products in django?
<p>I am trying to filter my products list by price specified by user(min and max price).I have two input box for taking price range.'price' is one of the column in my database table.I am getting error as int() argument must be a string or a number, not 'dict'.I have include my template file and small part of views file.</p>

<p>Models.py,</p>

<pre><code>class Add_prod(models.Model):
    book = models.CharField("Book Name",max_length=40)
    author = models.CharField("Author",max_length=30)
    price = models.PositiveIntegerField("Price")
    image = models.ImageField(upload_to='images',null=True)
    cat = models.ForeignKey(Add_cat,on_delete=models.PROTECT)

    def __unicode__(self):
        return "%s" % (self.cat)
</code></pre>

<p>My template file, </p>

<pre><code>&lt;p&gt;Price&lt;/p&gt;
&lt;input type="text" name="min_price" maxlength="4" size="3" &gt;
to &lt;input type="text" name="max_price" maxlength="4" size="3"&gt; 
&lt;input type="submit" value="Go"&gt;
</code></pre>

<p>views.py,</p>

<pre><code>@csrf_protect  
def welcome_user(request): 
    if 'min_price' in request.GET:
        filter_price1 = request.GET.get('min_price')
        filter_price2 = request.GET.get('max_price')
        if filter_price1 =='':
            filter_price1=0
        if filter_price2=='':
            filter_price2=Add_prod.objects.all().aggregate(Max('price'))
        my_products = Add_prod.objects.filter(price__range=(filter_price1,filter_price2))
        context = { "products":my_products}
   return render(request,"welcome-user.html",context)
</code></pre>

<p>I also tried like this,</p>

<pre><code>my_products = Add_prod.objects.raw('SELECT * FROM books_add_prod where price between filter_price1 and filter_price2')
</code></pre>