简体   繁体   中英

'tuple' object has no attribute 'all'

I am trying to develop a django web portal that contains a form which needs to be populated from two models. I am basically doing this..

class PositionForm(forms.ModelForm):
    position = forms.ModelChoiceField(PraveshEnums.POSITIONS)
    status = forms.ModelChoiceField(PraveshEnums.STATUS_OPTIONS)
    domain = forms.ModelChoiceField(queryset=Domain.objects.all())
    subdomain = forms.ModelChoiceField(queryset=Subdomain.objects.all())

However when I try loading that view, it gives

'tuple' object has no attribute 'all'

error.

I have been trying several sources online but haven't been able to find any reason why it is happening. Appreciate if anyone can help me in this. Thanks.

ModelChoiceField has single required argument: queryset. You are not passing a queryset for position and status fields.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM