Re: Get Top 10 Books by Rating and User

2009-07-20 Thread The Danny Bos
Andrew, I got lazy and installed 1.1, worked out I was able to quite easily. Your code worked perfectly. One more twist, is it possible to also match it against a Tag in a Books tags? For instance, 'Book Name' has the tags "Vampire, Blood, Beachball". I want to display the Top 10 Vampire books.

Re: Get Top 10 Books by Rating and User

2009-07-20 Thread The Danny Bos
That's fine Andrew. I appreciate it ... d On Jul 21, 12:44 am, Andrew Fong wrote: > Unfortunately, it looks the aggregation / sum stuff is in the SVN > version only for now. > > I'm not aware of any other way to do this with the Django 1.0 ORM > though. As a fallback, you could rely on raw

Re: Get Top 10 Books by Rating and User

2009-07-20 Thread Andrew Fong
Unfortunately, it looks the aggregation / sum stuff is in the SVN version only for now. I'm not aware of any other way to do this with the Django 1.0 ORM though. As a fallback, you could rely on raw SQL I suppose. http://docs.djangoproject.com/en/1.0/topics/db/sql/ Sorry I couldn't be more helpf

Re: Get Top 10 Books by Rating and User

2009-07-20 Thread The Danny Bos
I'm not able to use anything over Django 1.0.2. Does SUM work for this version, I'm getting the error: Could not import #.views. Error was: cannot import name Sum Is there another way around this? Thanks for your time and energy guys, d On Jul 21, 12:22 am, Andrew Fong wrote: > The rel

Re: Get Top 10 Books by Rating and User

2009-07-20 Thread Andrew Fong
The relevant documentation btw: http://docs.djangoproject.com/en/dev/topics/db/aggregation/ http://docs.djangoproject.com/en/dev/topics/db/queries/#lookups-that-span-relationships On Jul 20, 10:18 am, Andrew Fong wrote: > Assuming your models are like this: > > class Book(models.Model): >     n

Re: Get Top 10 Books by Rating and User

2009-07-20 Thread Andrew Fong
Assuming your models are like this: class Book(models.Model): name = models.CharField(max_length=128) class User(models.Model): is_staff = models.BooleanField(default=False) class Rating(models.Model): user = models.ForeignKey(User) score = models.IntegerField(default=3) boo

Get Top 10 Books by Rating and User

2009-07-20 Thread The Danny Bos
Hey there, I'm looking at getting a Top 10 of all Books on a site, but only where rated by users of a certain Group. Here's what I've got so far: book = Book.objects.all() Somewhat impressive, hey? - So, my tables/models are Book, Rating, User. - I save all ratings in Rating like so

Get Top 10 Books by Rating and User

2009-07-20 Thread The Danny Bos
Hey there, I'm looking at getting a Top 10 of all Books on a site, but only where rated by users of a certain Group. Here's what I've got so far: book = Book.objects.all() Somewhat impressive, hey? - So, my tables/models are Book, Rating, User. - I save all ratings in Rating like so