Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.4k views
in Technique[技术] by (71.8m points)

python - (Django) When I try to load fixture file into my database, I keep getting field clash error

When I try to load fixture data into my database, I get this error message

api.Player.team: (models.E006) The field 'field_name' clashes with the field 'field_name' from mode

my model only consist of one model which is Player

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()

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

It could be that in this line

team = pos = models.CharField(max_length=5, default="")

You use the same attribution for two variables (team and pos). I would separate them, even if the field has same max_length.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...