Python – How to get the label of a choice in a Django forms ChoiceField


I have a ChoiceField, now how do I get the "label" when I need it?

class ContactForm(forms.Form):
     reason = forms.ChoiceField(choices=[("feature", "A feature"),
                                         ("order", "An order")],

form.cleaned_data["reason"] would only give me "feature" or "order" or so.

Best Solution

See the docs on Model.get_FOO_display(). So, should be something like :


In a template, use like this:

{{ OBJNAME.get_FIELDNAME_display }}