Hey I am attempting to initialize a new database, but I am running into some issues setting up the migrations. The error I am getting appears to stem from setting up my form
You cannot execute queries during the initialization of the app registry. Your choices.py
file is indirectly imported during this time, resulting in the error. To fix this issue, you can pass a callable to choices
:
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)