#28078: Could not use fileld as part of expression when annotate key shadows 
model
field
-------------------------------------+-------------------------------------
               Reporter:  Pavel      |          Owner:  nobody
  Patrin                             |
                   Type:             |         Status:  new
  Uncategorized                      |
              Component:  Database   |        Version:  1.10
  layer (models, ORM)                |
               Severity:  Normal     |       Keywords:
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 Could not use fileld as part of expression when annotate key shadows model
 field

 For example i have a model

 {{{
     class MyModel(Model):
         grouping_field = TextField()
         amount_field_1 = IntegerField()
         amount_field_2 = IntegerField()


     queryset = MyModel.objects.values('grouping_field')

     # This is ok!
     queryset.annotate(amount_field_1=Sum('amount_field_1'))

     # This triggers error!
     # {FieldError}Cannot compute Sum('<CombinedExpression:
 F(amount_field_1) + F(amount_field_2)>'): '<CombinedExpression: ...>' is
 an aggregate
     queryset.annotate(
         amount_field_1=Sum('amount_field_1'),
         amount_field_2=Sum(F('amount_field_1') + F('amount_field_2')),
     )
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28078>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/054.bc7e0b4e3a74e6a4958a4d3413209baa%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to