change the default value choicefield

8 views
Skip to first unread message

Helton Alves

unread,
Apr 27, 2014, 10:15:32 AM4/27/14
to django...@googlegroups.com
Hi guys, I'm new here on the list.
I have a question.
yesterday I needed create a form with some fields and one the field was using select with choicefield.
I needed edit in label default of select.

was as follows:
<option>------------</option>

I wanted like this:
<option>Your state</option>

I done like this:

get the tuple with all states using the localflavor.br.br_states
I have all states in STATE_CHOICES

add on top of tupla like this:
STATE_CHOICES = ((None, u'Your state'),) + STATE_CHOICES

and then like this:
state = forms.ChoiceField(choices=STATE_CHOICES, required=False)

so I got what I wanted but but I think this resolution was not the best.
could someone show me other resolution more elegant?

Reply all
Reply to author
Forward
0 new messages