django表格下拉列表中包含所有用户

Tho*_*mel 14 django django-forms

我想创建一个表单,其中包含所有用户的下拉列表.我这样试过,没有运气.

class ContactFilterByClassificationForm(forms.Form):
   kam = forms.ChoiceField(choices=User.objects.all())
Run Code Online (Sandbox Code Playgroud)

Ben*_*mes 25

你想用一个ModelChoiceField.

class ContactFilterByClassificationForm(forms.Form):
    kam = forms.ModelChoiceField(queryset=User.objects.all())
Run Code Online (Sandbox Code Playgroud)