在下面的代码中,一些具有
示例:
blank=True
的字段仍然是必填项,不能为Null
。示例:
# Skill train timer
class SkillTrainingTimer(models.Model):
"""
Character Training timer, keep track fo what skill is in training, and when it is done
"""
character = models.ForeignKey(Character, unique=True)
skill = models.ForeignKey(Skill, blank=True)
trainingground = models.ForeignKey(TrainingGround, verbose_name='Training ground')
timer = models.DateTimeField()
现在我需要做的是:
train_skill = SkillTrainingTimer(
character=some_character_obj,
trainingground=some_trainingground_obj,
timer = fatetime.datetime.now()
)
train_skill.save()
出现了“skill cannot be Null
”的错误提示。我在很多模型和函数中都遇到了这个问题,目前的解决方法是在其中填入一些无用的数据。