Hi I have a Django form:
BAR_CHOICES = (
('1', 'Cheers'),
('2', 'The Blue Oyster'),
...
)
class ProjectInfoForm(forms.Form):
foo = forms.ChoiceField(
CHOICES = BAR_CHOICES,
)
...
of course when I save this data to a model the values are stored as integers in the db. Now, when I grab these values from the saved data they are integers. What is the best approach for getting the choice strings they are associated with. Should I import the BAR_CHOICES into the template?
Django provides a way to directly fetch the related string. Take a look here
Update:
Example:
In the template you could simply do
{{project.get_foo_display}}