2011-10-12 90 views
0

數我的下一個型號:整理相關對象

class Sentence(models.Model): 
    text = models.CharField(max_length=200)  
    language = models.ForeignKey(Language) 
    pub_date = models.DateTimeField() 

class Traduction(models.Model): 
    sentence_from = models.ForeignKey(Sentence, related_name='st_traductions_from') 
    sentence_to = models.ForeignKey(Sentence, related_name='st_traductions_to') 

我想一句與他們相關的TRADUCTION對象的數量對象的順序。我試了一下:

sentences = Sentence.objects.annotate(num_traductions=Count('st_traductions_from')) \ 
      .order_by('-num_traductions') 

但它提高了一個異常,當我重複它:

Caught DatabaseError while rendering: This query is not supported by the database 

我使用的AppEngine和Django的nonrel。

謝謝。

回答