[Fixed]-Django – Cannot resolve keyword 'total' into field

1👍

Why don’t you try this? ie, access the total method through Cart instance.

[i.total() for i in Cart.objects.filter(client=request_user, ordered=False)]

0👍

You need to create total function which will take price of each object you filter on the basis of client OR you can right query as follows:

total = 0

    for i in Cart.objects.filter(client=request_user, ordered=False).all():
        #print i.price
        total = total+i.price

You can’t write values('total'), as you don’t have any field in your card model as total.

Leave a comment