Here is my Django model
class author(models.Model):
name = models.CharField('name',max_length=140)
datamode = models.CharField(max_length=1, default='A', choices=DATAMODE_CHOICE)
def __str__(self):
return '%s' % (self.name)
While I use this class author as a foreign key in another class as follows:
class books(models.Model):
NEW_FLAG=(('N','New'),('O','Old'))
name = models.CharField('name',max_length=140)
author = models.ForeignKey(author, blank=True, null=True)
When I enter the new book details in admin it shows:
IntegrityError: Column 'author_id' cannot be null.
Now it’s working i simply dropped my database and again i created a newone. Anyway thanks to everyone.