如何按父母显示分类顺序?

时间:2013-11-01 21:09:10

标签: django django-models

我有模特:

class Category(models.Model):
    parent = models.ForeignKey('self', null=True, blank=True)
    name = models.CharField(max_length=200)

    class Meta:
        db_table = 'categories'
        ordering = ['parent']

但在管理员中我得到:

Infinite loop caused by ordering.

如何显示父订购的类别?

我想对这样的类别进行排序:

category 1
children of category 1
children of category 1
children of category 1 (category 1a)
children of category 1a
children of category 1
category 2
children of category 2
children of category 2
... etc

0 个答案:

没有答案