Django templates: verbose version of a choice
In Django templates you can use the "get_FOO_display()
" method, that will return the readable alias for the field, where 'FOO' is the name of the field.
Note: in case the standard FormPreview
templates are not using it, then you can always provide your own templates for that form, which will contain something like {{ form.get_meal_display }}
.
The best solution for your problem is to use helper functions. If the choices are stored in the variable CHOICES and the model field storing the selected choice is 'choices' then you can directly use
{{ x.get_choices_display }}
in your template. Here, x is the model instance. Hope it helps.