开发者

django form dropdown with all users in it

开发者 https://www.devze.com 2022-12-15 06:32 出处:网络
I want to create a form which has a dropdown with all users in it. I tried it like this, with no luck.

I want to create a form which has a dropdown with all users in it. I tried it like this, with no luck.

开发者_JS百科class ContactFilterByClassificationForm(forms.Form):
   kam = forms.ChoiceField(choices=User.objects.all())


You want to use a ModelChoiceField.

class ContactFilterByClassificationForm(forms.Form):
    kam = forms.ModelChoiceField(queryset=User.objects.all())
0

精彩评论

暂无评论...
验证码 换一张
取 消