﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
4620	Custom labels for choices in ModelChoiceField	Bill Fenner <fenner@…>	Jacob	"I wanted to display a different value than the str() for a certain ModelChoiceField I was building.  I added a func arg to both ModelChoiceField and QuerySetIterator to allow passing a function to change the behavior of the labels - e.g.,
{{{
    field = forms.ModelChoiceField(IESGLogin.objects.all(), func = lambda ad: ""%s, %s"" % (ad.last_name, ad.first_name))
}}}
to get ""Fenner, Bill"" instead of the default __str__ representation of ""Bill Fenner"".

ModelMultipleChoiceField is similarly modified, and you can of course call more complex functions

{{{
    field2 = ModelMultipleChoiceField(IDState.objects.all(), func=lambda f:truncate_words(str(f),2))
}}}

"		closed	Forms	dev		fixed			Accepted	1	0	0	0	0	0
