In the code below, somehow the fields that have blank=True
are still required and cannot be Null
Example:
# 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()
and now i do:
train_skill = SkillTrainingTimer(
character=some_character_obj,
trainingground=some_trainingground_obj,
timer = fatetime.datetime.now()
)
train_skill.save()
It starts complaining skill cannot be Null
. I have this in a lot of models and functions and so far i just dumped some useless data in it.
null=True
sets NULL on the column in your DB.
blank=True
determines whether the field will be required in forms. This includes the admin and your own custom forms. If blank=True
then the field will not be required, whereas if it's False the field cannot be blank. Hope this helps!
You have to add the null=True
argument on the field definition, preferably before a syncdb (or you can migrate with South)
skill = models.ForeignKey(Skill, blank=True, null=True)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With