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.
- Django form to display user attributes
- Google App Engine Django Standard Environment: Error: Server Error
- Django form and many2many.through field
- How to add extra parameters to html tag from base django
Source:stackexchange.com