Migration clashes with forms.py

前端 未结 5 538
轮回少年
轮回少年 2020-12-11 05:12

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

5条回答
  •  时光取名叫无心
    2020-12-11 05:59

    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

提交回复
热议问题