(Django)当我尝试将夹具文件加载到我的数据库中时,我不断收到字段冲突错误
Posted
技术标签:
【中文标题】(Django)当我尝试将夹具文件加载到我的数据库中时,我不断收到字段冲突错误【英文标题】:(Django) When I try to load fixture file into my database, I keep getting field *** error 【发布时间】:2021-04-24 06:46:04 【问题描述】:当我尝试将夹具数据加载到我的数据库中时, 我收到此错误消息
api.Player.team: (models.E006) 字段“field_name”与模式中的字段“field_name”冲突
我的模型只包含一个模型,即播放器
class Player(models.Model):
class Meta:
db_table = 'player'
pos = models.CharField(max_length=2, default="")
name = models.CharField(max_length=30, default="")
age = models.PositiveIntegerField()
posRank = models.PositiveIntegerField()
team = pos = models.CharField(max_length=5, default="")
throwAtt = models.PositiveIntegerField()
throwYd = models.PositiveIntegerField()
throwTD = models.PositiveIntegerField()
interception = models.PositiveIntegerField()
rushAtt = models.PositiveIntegerField()
rushYd = models.PositiveIntegerField()
rushTD = models.PositiveIntegerField()
rushAvgYd = models.FloatField()
target = models.PositiveIntegerField()
rec = models.PositiveIntegerField()
recYd = models.PositiveIntegerField()
recAvgYd = models.FloatField()
recTD = models.PositiveIntegerField()
totalTD = models.PositiveIntegerField()
fumble = models.PositiveIntegerField()
fpts = models.FloatField(null=True)
ppr = models.FloatField()
totGames = models.PositiveIntegerField()
【问题讨论】:
【参考方案1】:可能在这一行
team = pos = models.CharField(max_length=5, default="")
您对两个变量(团队和职位)使用相同的属性。即使字段具有相同的 max_length,我也会将它们分开。
【讨论】:
以上是关于(Django)当我尝试将夹具文件加载到我的数据库中时,我不断收到字段冲突错误的主要内容,如果未能解决你的问题,请参考以下文章