Re: GROUP results in views.py

2009-11-01 Thread TiNo
On Fri, Oct 30, 2009 at 22:10, Javier Guerra wrote: > > On Fri, Oct 30, 2009 at 4:05 PM, TiNo wrote: > > SQL's GROUP BY is made for this isn't it? > > no, it's not. > > SQL's GROUP BY discards 'individual' rows off the result, showing only > 'grouping'

Re: GROUP results in views.py

2009-10-30 Thread Javier Guerra
On Fri, Oct 30, 2009 at 4:05 PM, TiNo wrote: > SQL's GROUP BY is made for this isn't it? no, it's not. SQL's GROUP BY discards 'individual' rows off the result, showing only 'grouping' rows. -- Javier --~--~-~--~~~---~--~~ You received this

Re: GROUP results in views.py

2009-10-30 Thread TiNo
On Fri, Oct 30, 2009 at 15:05, Tom Evans wrote: > SQL cant do this, so do it in python... SQL's GROUP BY is made for this isn't it? And it is also possible in django. I guess this is what you need:

Re: GROUP results in views.py

2009-10-30 Thread Tom Evans
SQL cant do this, so do it in python... items = ItemOwned.objects.filter(user=id) data = { } for item in items: cur_set = data.get(item.setId, {'setId': item.setId, 'items':[]}) cur_set['items'].append({'id': item.id, }) data[item.setId] = cur_set return

Re: GROUP results in views.py

2009-10-30 Thread The Danny Bos
Any ideas anyone? I'm completely stumped ... On Oct 30, 12:59 pm, The Danny Bos wrote: > If helpful, here's the table structure. > > class ItemOwned(models.Model): >         user = models.ForeignKey(User) >         item = models.ForeignKey(Item) > > class

Re: GROUP results in views.py

2009-10-29 Thread The Danny Bos
If helpful, here's the table structure. class ItemOwned(models.Model): user = models.ForeignKey(User) item = models.ForeignKey(Item) class Item(models.Model): set = models.ForeignKey(Set) number = models.IntegerField() class Set(models.Model): title =

GROUP results in views.py

2009-10-29 Thread The Danny Bos
Hey there, I've got the below query, generating the below JSON. But I want to group them by "setId", can I do this in my query or in views.py to create a JSON file like the one at the bottom? Regroup in a template would be great, but doesn't work in views ... views.py: items =