Reputation: 133
Here is my Chapter model code:
class Chapter(models.Model):
name = models.CharField(max_length=180)
is_canon = models.BooleanField(default=True)
series_id = models.ForeignKey('Series', on_delete=models.CASCADE,
blank=True, null=True)
def __str__(self):
return self.name
When running python3 manage.py makemigrations
, I provided a one off value of 'NULL' for the new field series_id
in order to populate existing rows, when I should have backed out and added blank=True, null=True
to the definition, as it is now in the code provided above. So, now, I want to run python3 manage.py migrate
, but of course the migration fails because I've got a bunch of 'NULL' strings in places where django is expecting actual NULL values/integer values.
How to I get rid of those 'NULL' values and reset things so I can migrate?
Thank you for your time.
Upvotes: 0
Views: 46
Reputation: 436
Adding to Pythonista comment. You could roll back to the previous migration. Delete the migration file and create it once again. That is the cleanest way in my opinion.
Upvotes: 1