3👍
✅
I figured it out! Lesson learned: read the whole stacktrace, not just the last line. In this case, the offensive line was in my views.py
:
File "/path/to/myproject/myapp/views.py", line 8, in <module>
existing_model = MyExistingModel.objects.all()[0]
Like I said, MyExistingModel
has only one instance, and this line set that instance to the local variable existing_model
for use in the views.py
code.
I still don’t understand why makemigrations
would need to run views.py
. But it does, apparently! In doing so, MyExistingModel
was imported from models.py
, including the new fields. But those fields hadn’t yet been migrated. Thus, OperationalError.
👤ki9
Source:stackexchange.com