If you have not indicated yet that your field is optional, you will need to indicate its value each time you create an object. In your case, you cannot do this, you will have to do one of these things:
Here's how to make the field optional:
class B(models.Model): a = models.ForeignKey(A) name = models.CharField(max_length=200) mydate = models.DateTimeField('party date', blank=True, null=True)
This is how you set the default value:
import datetime class B(models.Model): a = models.ForeignKey(A) name = models.CharField(max_length=200) mydate = models.DateTimeField('party date', default=datetime.datetime.now)
source share