Re: Group by for querysets

2008-05-09 Thread Eric Abrahamsen
> Awesome! Thanks much, Eric! My pleasure... Just noticed there's a typo in the second part, should be columns.setdefault..., not blocks. Hooray for native group_by support in the ORM! I didn't realize that was already in there. --~--~-~--~~~---~--~~ You received

Re: Group by for querysets

2008-05-09 Thread James Bennett
On Fri, May 9, 2008 at 12:47 PM, Chris <[EMAIL PROTECTED]> wrote: > Does django carry something similar to what I am looking for? If not, > would a group_by feature be something worth adding to django? If you're using a recent Django trunk checkout (after the queryset-refactor merge), there is so

Re: Group by for querysets

2008-05-09 Thread gmacgregor
On May 9, 4:57 pm, Eric Abrahamsen <[EMAIL PROTECTED]> wrote: > (Don't forget to reply to the list...) Apologies... didn't realize I hit "Reply to author" > The documentation for the groupby function is notoriously obscure, but > it's actually simple to use. It generates pairs where the first i

Re: Group by for querysets

2008-05-09 Thread Eric Abrahamsen
> This sounds like it might do what I need... Care to share a code > example? > > > Greg (Don't forget to reply to the list...) The documentation for the groupby function is notoriously obscure, but it's actually simple to use. It generates pairs where the first item is the common key for a

Re: Group by for querysets

2008-05-09 Thread Eric Abrahamsen
In the meantime, you can use the groupby template tag for simple grouping operations in the template, or else I've had success using the itertools.groupby function in the view, and then passing your queryset as a dictionary or list of tuples to the template. It will be nice to have native

Re: Group by for querysets

2008-05-09 Thread [EMAIL PROTECTED]
Their is a thread here regarding the GSOC student's work: http://groups.google.com/group/django-developers/browse_thread/thread/f83457fc3cdb235d On May 9, 1:41 pm, gmacgregor <[EMAIL PROTECTED]> wrote: > On May 9, 2:37 pm, gmacgregor <[EMAIL PROTECTED]> wrote: > > > Something like it is being "co

Re: Group by for querysets

2008-05-09 Thread gmacgregor
On May 9, 2:37 pm, gmacgregor <[EMAIL PROTECTED]> wrote: > Something like it is being "considered" but nothing for > sure:http://code.djangoproject.com/ticket/3566 Whoops, I lied: check out the (currently) last comment made by Russ M on the ticket page: "For the benefit of those that haven't h

Re: Group by for querysets

2008-05-09 Thread gmacgregor
On May 9, 1:47 pm, Chris <[EMAIL PROTECTED]> wrote: > Is there a group_by method when getting querysets? Nope... nothing of the sort. You'll have to write raw SQL for that. I'm struggling with the same thing right now. > Check out the following example. > ... > events_by_group = > SportsEvent.o