Reputation: 5371
I have the following in one of my forms:
self.fields['advisor'].queryset = User.objects.filter(groups__name='advisor')
The only problem is that it displays the username
in the drop down box. What I would like to do is display the first_name
then last_name
to make it more human readable.
Any ideas?
Upvotes: 2
Views: 140
Reputation: 25154
The ModelChoiceField
has a label_from_instance
method which can be changed in a subclass to use something other than the model __unicode__
method. https://docs.djangoproject.com/en/1.3/ref/forms/fields/#django.forms.ModelChoiceField.empty_label
Upvotes: 3