我有一个像下面的Python Django models.py -
class Nx2FwComponent(models.Model):
name = models.CharField(max_length=10)
def __unicode__(self):
return self.name
class Nx2FwComponentWithPath(models.Model):
nx2FwComponent = models.ForeignKey(Nx2FwComponent)
path = models.CharField(max_length=100, unique=True)
def __unicode__(self):
return (self.path + '/' + str(self.nx2fwComponent))
如图所示填充数据库表 -
sqlite> select * from config_nx2fwcomponent;
1|mfw
2|mba
3|feb
4|ib_ipv4n6
sqlite> select * from config_nx2fwcomponentwithpath;
1|V:\rels\mba|2
在我的views.py中,当我跑 -
时Nx2FwComponentWithPath.objects.all()
我收到此错误 -
(Pdb) Nx2FwComponentWithPath.objects.all()
*** AttributeError: 'Nx2FwComponentWithPath' object has no attribute 'nx2fwComponent'
有什么问题?