我按照mptt文档中的描述创建了一个类。
class Locations(MPTTModel):
title = models.CharField(max_length=100)
parent = TreeForeignKey('self', null=True, blank=True, related_name='children')
def __unicode__(self):
return self.title我在做一份手册上写的表格
class RealtyAdminModelForm(forms.ModelForm):
location = TreeNodeChoiceField(queryset=Locations.tree.all(),
level_indicator=u'+--')
class Meta:
model = Realty但是django给出了以下错误:type object 'Locations' has no attribute 'tree'
为何会这样呢?
发布于 2013-09-20 12:45:25
我不明白为什么在docs (http://django-mptt.github.io/django-mptt/forms.html)中的“树”,但正确的是“对象”:
class RealtyAdminModelForm(forms.ModelForm):
location = TreeNodeChoiceField(queryset=Locations.objects.all(),
level_indicator=u'+--')
class Meta:
model = Realtyhttps://stackoverflow.com/questions/18914951
复制相似问题