Reputation: 163
I am putting an image field in a model called Students. Everything is working fine until I put an image field into the model. I am getting the following even I put blank and null as True. It should work fine. Following is the detail information.
django.db.utils.IntegrityError: NOT NULL constraint failed: new__genius_students.image
This is the model
class Students(models.Model):
created_by = models.ForeignKey(
User, on_delete=models.SET_NULL, default=1, null=True)
name = models.CharField(max_length=200, null=True)
image = models.ImageField(upload_to='images/', null=True, blank=True)
dob = models.DateField(null=True, verbose_name='Date of Birth')
age = models.IntegerField()
I had tried many things like clearing cache and cookie. But No luck.
Upvotes: 1
Views: 628
Reputation: 3118
Go to the migrations folder and delete manually files that have 000*_lastAction_blah-blah type of name, you can delete, probably all, but 0001_initial.py file. After that run ./manage.py make migrations app_you_are_updateing, it should update your database.
Upvotes: 1