Hi there!
I have a model with "disposals" and a model with "salesman". I want to get the average discount of everye salesman. Here's what I'm trying:
sm = Disposal.objects.annotate(average_discount=Avg('discount')).values('average_discount','sm__fname','sm__lname').order_by('-discount')
for s in sm:
data[0] = data[0]+s.sm__fname+','+s.sm__lname+','+str(s.average_discount)
Now I get this error:
Disposal object has no attribute sm__fname
The query runs fine when I execute it in the django shell - but how can I access the values? Thank you very much!