我有模型:
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