下面的视图可以很好地工作,它利用了“update_or_create”功能,当有东西存在时,它会非常出色地更新记录。但是,如果它不存在并且必须使用create选项来创建一个新记录,我会得到以下错误:
TypeError at /selectteams/1025/3/
'soccerseasonid_id' is an invalid keyword argument for this function
视图如下:
^{pr2}$以下型号:
class StraightredSeason(models.Model):
seasonid = models.IntegerField(primary_key = True)
seasonyear = models.CharField(max_length = 4)
seasonname = models.CharField(max_length = 36)
def __unicode__(self):
return self.seasonid
class Meta:
managed = True
db_table = 'straightred_season'
class UserSelection(models.Model):
userselectionid = models.AutoField(primary_key=True)
campaignno = models.CharField(max_length=36,unique=False)
user = models.ForeignKey(User, related_name='selectionUser')
teamselection1or2 = models.PositiveSmallIntegerField()
teamselectionid = models.ForeignKey('straightred.StraightredTeam', db_column='teamselectionid', related_name='teamID')
fixturematchday = models.IntegerField(null=True)
soccerseason = models.ForeignKey('straightred.StraightredSeason', db_column='soccerseasonid', related_name='fixture_seasonUserSelection')
class Meta:
managed = True
db_table = 'straightred_userselection'
任何帮助都将不胜感激,非常感谢,艾伦。在
它看起来像是在使用你的默认值,你指定了“soccerseasynid”而不是“soccerseasynd”足球季“你的id”应该有用。在
相关问题 更多 >
编程相关推荐