我无法查询 django 模型。
模型如下。
class DeviceLevelMapping(models.Model):
device = models.ForeignKey(DeviceDetails)
level1 = models.ForeignKey('Level1Detail')
level2 = models.ForeignKey('Level2Detail')
level3 = models.ForeignKey('Level3Detail')
level4 = models.ForeignKey('Level4Detail')
level5 = models.ForeignKey('Level5Detail')
level6 = models.ForeignKey('Level6Detail')
level7 = models.ForeignKey('Level7Detail')
class Meta:
db_table = 'device_level_mapping'
当我触发查询DeviceLevelMapping.objects.filter(level1_id = l_id)
时,它会unknown column
显示 DeviceLevelMapping.id`。
问题出在哪里?
已编辑
class Level1Detail(models.Model):
level1_id = models.IntegerField(primary_key=True)
level1_name = models.CharField(max_length=256L)
organization = models.ForeignKey('OrganizationDetails')
class Meta:
db_table = 'level1_detail'