Saturday, January 30, 2021

Re: multiplying two fields

This will work 

data = Articles.objects.all().annotate(result=ExpressionWrapper(F('cost_buy') * F('quantity') , output_field=FloatField()))
now data is a queryset. so you can do something like this
data[0].result
data.values("result")

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAJPiQOQR%3DpxnMTNKajOxiNsUh--14TGMH-Ao5bKHr7LM%2B3PPUA%40mail.gmail.com.

No comments:

Post a Comment