Honza Král wrote:
> it occured before on the mailing list...
> 
> if you add select_related(), it will work...
> 
> the problem is that specifying ordering like this doesn't force the
> join in the query so you might end up with a query that sorts on
> something that just isn't there...

That didn't work either:

     Book.objects.all().select_related()
         .order_by('-bookshop_bookstat.avg_rating')[0:10]

still gives me:

     ERROR: missing FROM-clause entry for table "bookshop_bookstat"


Perhaps I'm doing something else wrong. These are my models:

-----------------------------------------------------------------
class Book(models.Model):
     ....

class BookStat(models.Model):
     book = models.OneToOneField(Song, related_name='stats')
     avg_rating = models.FloatField(max_digits=2, decimal_places=1)
     ...
-----------------------------------------------------------------

We're doing this because the statistics are calculated in cron jobs.

Btw, what if a certain book doesn't have statistics (yet)? Should I be 
dropping back into SQL? :-)


  - bram

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to