我创建了一个类,如 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'
为什么会这样?