Monday, January 4, 2021

How can I multiply 2 or more fields in django views or models

Hi everyone, i'm a new in django and python and i have a problem

I had a inventory app and I want to multiply 2 fields, coust_buy and quantity, but when execute this query:
views.py
        data = Articles.objects.all().annotate(result=F('coust_buy') * F('quantity'))

the results is this (img down)



what wrong with my query ? b

--
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/f7e5dcbe-f6dd-47a1-8412-42c14aa70e95n%40googlegroups.com.

No comments:

Post a Comment