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 defin
init via callable...
def get_provinces():
province_choices = []
for province in ProvinceCode.objects.filter(country_code_id=1).order_by('code'):
province_choices.append((province.code, province.code))
return province_choices
class MemberForm(forms.Form):
provinces = forms.ChoiceField(label='Provinces',
choices=get_provinces, required=True)
Refer here - Django relation error when running make migrations