can't multiply sequence by non-int of type 'QuerySet'

I just start learn django, and i want to ask to solve my problem

here my models.py

class LotSell(models.Model):
    rate = models.DecimalField(max_digits=5, decimal_places=4)

at django admin input with value 0,0666 or something

views.py

def result(request):
    price_buyer = request.GET['price_buyer']
    temp_price = LotSell.objects.values_list('rate')
    tot_price = price_buyer * temp_price
    data = {
        'tot_price': tot_price,
    }
    return render(request, 'resultsell.html', data)

resultsell.html

<body>
{{tot_price}}
</body>

index.html

<form action="{% url 'resultsell %}" method="get">
{% csrf_token %}
<input type="text" name="price_buyer">
<br>
<button type="submit"> Submit</button
</form>

in the end, i want to showing to user with the total price by: rate (input by admin as decimal or percentage) multiply the price_buyer where input by user

Thank you

This query returns a queryset containing a list of lists. You need to access the individual values to do anything with those values.

I would suggest you experiment with this in the Django shell to get used to working with data like this.

1 Like