Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

class ContactFilterByClassificationForm(forms.Form):
   kam = forms.ChoiceField(choices=User.objects.all())
like image 732
Thomas Kremmel Avatar asked Jan 05 '10 08:01

Thomas Kremmel


1 Answers

You want to use a ModelChoiceField.

class ContactFilterByClassificationForm(forms.Form):
    kam = forms.ModelChoiceField(queryset=User.objects.all())
like image 60
Ben James Avatar answered Nov 10 '22 21:11

Ben James