Migration clashes with forms.py
<p>The command <code>python manage.py makemigrations</code> fails most of time due to the <code>forms.py</code>, in which new models or new fields are referenced at class definition level.</p>

<p>So I have to comment each such definitions for the migration to operate. It's a painfull task.</p>

<p>I don't understand why the migration process import the <code>forms.py</code> module. I think that importing models modules should be sufficient.</p>

<p>Is there a way to avoid those errors ? </p>

<p>Thanks to @alasdair I understood my problem and found a workaround: I replace the original code in the <code>views.py</code> file</p>

<pre><code>from MyApp import forms
</code></pre>

<p>with</p>

<pre><code>import sys
if 'makemigrations' not in sys.argv and 'migrate' not in sys.argv:
    from MyApp import forms
</code></pre>

<p>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.</p>

python django django-forms django-migrations