getting cannot convert to male error in django?
You can get the choice display (so here the value for female_label
and male_label
) with the .get_gender_display()
method, so:
customer.get_gender_display()
Indeed, as the documentation on the .get_fieldname_display()
[Django-doc] says:
For every field that has
choices
set, the object will have aget_FOO_display()
method, whereFOO
is the name of the field. This method returns the “human-readable” value of the field.