﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
28078	Can't use field as part of expression when annotate key shadows model field	Pavel Patrin	nobody	"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')),
    )  
}}}

"	Cleanup/optimization	closed	Database layer (models, ORM)	1.10	Normal	invalid			Accepted	0	0	0	0	0	0
