The command python manage.py makemigrations
fails most of time due to the forms.py
, in which new models or new fields are referenced at class definition level.
So I have to comment each such definitions for the migration to operate. It's a painfull task.
I don't understand why the migration process import the forms.py
module. I think that importing models modules should be sufficient.
Is there a way to avoid those errors ?
Thanks to @alasdair I understood my problem and found a workaround: I replace the original code in the views.py
file
from MyApp import forms
with
import sys
if 'makemigrations' not in sys.argv and 'migrate' not in sys.argv:
from MyApp import forms
It works fine in my case, but I suppose there is a better way to know if the current process is a migration or not. If so, please advise.