[Solved]-Django, Cannot assign None, does not allow null values

17👍

 #for sql 'now()' value use
 published = models.DateField('Published', auto_now_add=True)
 #to allow sql null
 published = models.DateField('Published', null=True, blank=True)

5👍

You need to add the parameters “null=True, blank=True” to the definition of published, that way it won’t be created as a NOT NULL column in the database:

published = models.DateField('Published', null=True, blank=True)

Leave a comment