I have a ModelForm with a ModelMultipleChoiceField.
users = forms.ModelMultipleChoiceField(
widget=forms.SelectMultiple(attrs={'class': 'chzn-select'}),
queryset = User.objects.filter(...))
My list is displayed by username, as the default repr method of the model.
I want to display the first_name and the last_name without overloading the repr method, because I need username in other cases.
I wouldn’t like to get the values_list('id', 'first_name', 'last_name'), because later I don’t get a model list on save() but tuples.
Is there any setting/hack for this ?
You can alter the object representation by overriding label_from_instance, which is part of the ModelChoiceField class that ModelMultipleChoiceField inherits.
https://docs.djangoproject.com/en/1.3/ref/forms/fields/#django.forms.ModelChoiceField
https://docs.djangoproject.com/en/1.3/ref/forms/fields/#modelmultiplechoicefield