我正在尝试获取一个类别的所有孩子:
def list_sub(self, category_name):
# this will return the parent if exists
category = Category.objects.filter(seo_title__exact = seo_title).filter(lang__exact = 'pt-PT').filter(level__exact = 1)
if category:
# but this doesn't work and in the documentation there are no examples
# of how to get it. See link about the method
sub_categories = category.get_children()
http://django-mptt.github.com/django-mptt/models.html#get-children
更新1:
qc = Category.objects.filter(seo_title__exact = cat).filter(lang__exact = 'pt-PT').filter(level__exact = 1)
category = qc.get()
if category:
qsc = category.get_children()
sub_categories = qsc.get()
现在我收到此错误:“get() 返回了多个类别 - 它返回 7!查找参数为 {}”
谢谢