Hello,

Suppose I have a model my_model, with several fields, one of which is
x. Suppose it's based on an SQL table with the same name.

In SQL, I can:

select x, count(*)
from my_model
group by x

In order to get the number of rows with each value of x.

I'm not sure how to do that in django. The annotate method looks like
the closest thing, but it seems to depend on having many-to-many table
relationships.

Is there some easy way to do this in django that I'm missing? Seems
like there should be!

Thanks,
Gary
--~--~---------~--~----~------------~-------~--~----~
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