Skip to content Skip to sidebar Skip to footer

Django Localflavor Usstateselect() Inital Value

I'm trying to use the django localflavor widget USStateSelect() in a form, but I want the widget to have Nebraska selected by default. The Widget only accepts an attrs arg, so I'm

Solution 1:

You can set the initial value like so:

state = forms.CharField(widget=USStateSelect(), initial='NE')

or you can set it when you instantiate the form:

form = ExampleForm(initial={'state': 'NE'})

Post a Comment for "Django Localflavor Usstateselect() Inital Value"