Hi Guys,

I have two models, with a foreign key from the first two the second, and I
need make a kind of group py and count, I try this but don't works:

a =
Congresista.objects.filter(profesion=3).annotate(Count('partido_politico')).distinct('partido_politico')

'partido_politico' is the foreignkey in the model "Congresista"

Even i try this:

a =
Congresista.objects.filter(profesion=3).values('partido_politico','partido_politico__nombre').annotate(Count('partido_politico'))

when i do a.count() i get 28 records, but when i make something like:

for c in a:
    print c

I have 118 records.

Some idea?

-- 
Diego Andrés Sanabria
IngenierĂ­a de Sistemas Universidad Distrital
about:me http://www.google.com/profiles/diegueus9
cel 3015290609

Sent from Bogota, DC, Colombia

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to