Monday, January 4, 2021

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

Ok, i understood, can you show me how to multiply 2 fields?
really i can't to do that... i guess i in mental looping

i try to do that in views.py:
data = Articles.objects.all().annotate(result=F('coust_buy') * F('quantity')).output_field=FloatField('result')

and the result is this.... what to you think 😬

On Mon, Jan 4, 2021 at 2:06 PM Ayser shuhaib <embedded.manager@gmail.com> wrote:
Nothing wrong with the query, the problem is that you are trying to multiply two values of a different type.
You can fix that by converting the smallInteger value to decimal.

On Mon, 04 Jan 2021 at 23:01, jose angel encinas ramos <encinasj.angel@gmail.com> wrote:
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.

--
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/CAE0AZGK%3D8wTcc4kwc8tdYnw59HTRS2ncjLq%2BGNcLLEQwuam0wQ%40mail.gmail.com.


--
José Ángel Encinas
Ing. Tecnologias de la información


Cel:  6622267620 

  
                   Never give up...
   I     I  https://us04web.zoom.us/j/4514417813

--
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/CAF3iVr-hoXCQaC91TP2ARoLNzA4V3qQUOC1%3DMKWC7A-qfu%2BkHQ%40mail.gmail.com.

No comments:

Post a Comment