Python 3, Django 1.8.5, Postgres
I have a model Sites that has been working fine. I recently tried to add a field, airport_code, and migrate the data.>
Just now had the same error when I tried to migrate a SingletonModel to actually contain the necessary fields.
Reason for the error was that my Model A used some fields of this SingletonModel (as configurable values). And during instantation of model A during the migration process it obviously couldn't guarantee that my migration was safe.
A colleague had a wonderful idea. Make the default value for the field a function call, and therefor lazy.
Example:
class A (models.Model):
default_value = models.DecimalField(default: lambda: SingletonModel.get_solo().value, ...)
So therefor, my advice: Try and make the offending call (seen in stacktrace) a lazy one.