I changed my models.py file and when running migrate
I get this error. The property is a OneToOneField(). I have tried adding null=True
but that doesn't seem to fix it. It is also weird that even when I comment out the property and run makemigrations
followed by migrate
, I still get that exact same error. Is there a way to fix this? My model looks like this:
class Estimator(Employee):
avg_estimate = models.IntegerField()
class Job(models.Model):
created = models.DateTimeField(auto_now_add=True)
estimator = models.OneToOneField(Estimator, null=True)
address = models.CharField(max_length=100)
completed = models.BooleanField(default=False)
My guess is that you have created a migration without null=True, that won't migrate, then you created a second migration with null=True.
Running "migrate" will run both migrations in order, so the first one will fail again.
Assuming this is the case, then 1: delete the two most recent files in your migrations folder. (Open them first to confirm that they are creating the migrations as I described before deleting them). 2: run makemigrations again, with null=True in your models.py
This should create the equivalent of the second migration file, without the failing intermediate migration.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With