开发者

django form dropdown with all users in it

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜