Dave - I think you are having the same problem I had to begin with.

Using the ORM means you have to change your way of thinking.

Remember - the ORM isn't perfect, and there are instances where you either
need to use a raw SQL, or split the query up into multiple calls. In some
cases, doing things the 'right' way is actually the 'wrong' way, depending
on the data you are dealing with, and your indexes.

Put simply - Django does have, nor need, a 'group by' method - and if you
believe otherwise, it's because you haven't got used to the "Django
methology" yet.

Just my two cents worth.

Cal

On Fri, Sep 16, 2011 at 1:39 PM, Jani Tiainen <rede...@gmail.com> wrote:

> 16.9.2011 15:27, dave bl kirjoitti:
>
>> Hmm no I am not missing the point... I think the django devs are...
>> sqlalchemy _has_ a group by.
>>
>> So I simply want to do this sql statement(using the django orm):
>>
>> select foo, count(foo), from bar group by foo;
>>
>> I _could_ use a .extra method to do this(and get stuck on $databases)
>> ... or a loop... (non-sql). IMHO I should be able to do it via the
>> orm. If you can do it via the orm - how do I do it ?
>>
>>
> Bar.objects.values('foo').**annotate(Count('foo'))
>
> As written in Django documentation...
>
> --
>
> Jani Tiainen
>
>
> --
> 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+unsubscribe@**
> googlegroups.com <django-users%2bunsubscr...@googlegroups.com>.
> For more options, visit this group at http://groups.google.com/**
> group/django-users?hl=en<http://groups.google.com/group/django-users?hl=en>
> .
>
>

-- 
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