[BangPypers] Getting label of the choicefield in django form
Asif Jamadar
asif.jamadar at rezayat.net
Sat Oct 22 08:35:24 CEST 2011
I have django form which consist of one choice field with following choices
Choices = [('attr1', 1), ('attr1', 2), ('attr3',3), ('attr2',1), ('attr2',2), ('attr2', 3)]
If I do value = form.cleaned_data('value')
It is returning the value ( I,e attr1 or attr2) .in this case how can I get the label(or name) of the choicefield.
I tried
for val in cf.fields['value'].choices:
if val[0] == cf.cleaned_data['value']:
print val[1]
break
More information about the BangPypers
mailing list