2011-04-17 77 views
0

models.pyDjango的MPTT ORDER_BY錯誤

class Category(MPTTModel): 
    name = models.CharField(max_length=100) 
    slug = models.SlugField(max_length=200, unique=True) 
    parent = models.ForeignKey('self', blank=True, null=True, related_name='child') 
    image = models.ImageField(upload_to='gfx/category/image/', blank=True, null=True) 
    hidden = models.BooleanField(default=1) 
    created = models.DateTimeField(auto_now_add=True) 
    changed = models.DateTimeField(auto_now=True) 

class MPTTMeta: 
    order_insertion_by = ['name',] 

我的觀點:

categories = Category.tree.filter(level__lte=1) 

我將「創造」在我的模板樹的第一級訂單 - 如何做我這樣做? 我想:

categories = Category.tree.filter(level__lte=1).order_by('-created') 

請幫助...

回答