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
You need to read the documentation as always -
https://docs.djangoproject.com/en/3.1/ref/models/expressions/#using-f-with-annotations
It says that the output_field is a keyword argument for the annotate method.
On Fri, Jan 29, 2021 at 10:56 PM jose angel encinas ramos <
encinasj.an...@gmail.com>
tanks Ross, i fixed my error but now only show me this
>>> data = Articles.objects.all().annotate(F=('cost_buy') *
F('quantity')).output_field=FloatField('result')
>>> print(data)
>>>
what do you think?
On Fri, Jan 29, 2021 at 2:54 PM Ross Meredith wrote:
> Apologies, typo myself!
>
> That me
Apologies, typo myself!
That meant to say "typo" not "type".
On Fri, Jan 29, 2021 at 9:52 PM Ross Meredith wrote:
>
> data = Articles.objects.all().annotate(result=F('coust_buy') *
> F('quantity')).output_field=FloatField('result'),
>
> contains a type for the field "cost_buy" (i.e. not "cou
data = Articles.objects.all().annotate(result=F('coust_buy') *
F('quantity')).output_field=FloatField('result'),
contains a type for the field "cost_buy" (i.e. not "coust_by").
If that isn't it please give us the traceback.
On Fri, Jan 29, 2021 at 8:50 PM jose angel encinas ramos <
encinasj.an..
Guys gd evening
I need help,really i don't kwnow how to do a multiply two fields, have a
model called Articles.
class Articles(models.Model):
#models article
Nuevo = 'Nuevo'
Semi_nuevo = 'Semi_nuevo'
Usado = 'Usado'
Otros = 'Otros'
STATE_ACTUAL = (
(Nuevo, 'Nuevo'),
(Semi_nuevo,'Semi_nuevo'),
(
6 matches
Mail list logo