I'm trying to add a set of values belonging to id_jovenclub
def detalle_jc(request, id_jovenclub ):
jc = jovenclub.objects.get(pk=id_jovenclub)
datos=ingresos.objects.all()
print jc.ingresos_set.all()
**ing = ingresos.objects.aggregate(pk=id_jovenclub)**
natural=ing.natural
sum=0
for ingreso in jc.ingresos_set.all():
sum=ingreso.get_importe()
sum=(round((sum/jc.plan_gral)*100,2))
When I execute the code it gives me the following error:
'unicode' object has no attribute 'lookup'
I think it should be because aggregate
does not work with pk queries, but try with ing = ingresos.objects.annotate
and it does not work either.