I'm trying to sum the field "ownProduction", grouping it by the foreign key 
"market" (using the market's human readable name, __name from the Market 
table) and the week number (which is built-in function __year of the date 
field "dateContract").
However, when I try to read the results of the query in the last line in 
the code example below., I get the error:

"'dict' object has no attribute 'ownProduction'" 

So "ownProduction" is to my surprise not a field in the query.
What am I doing wrong?

    contract_query = (Project.objects.all()
                             .filter(department=department_id)
                             .filter(datePipeline__year=year)
                             .filter(stage="WON")
                             .annotate(week=ExtractWeek('dateContract'))
                             .values('week','market__name')
                             .annotate(Sum('ownProduction'))
                         )
    for contract_row in contract_query:
        contract_sum = contract_row.ownProduction

It doesn't change anything using
                             .annotate(ownProduction = Sum('ownProduction'))



cheers + thanks, Mikkel

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/525b78b7-ada3-4a49-818a-c02fc1bf51b0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to