Thursday, 15 January 2015

Crispy Forms: Default selected value for FieldSet -



Crispy Forms: Default selected value for FieldSet -

i have list of items i'm populating crispy forms choicefield

for life of me, can't figure out how set item in region_choice selected default.

regions = { 'us': 'us value', 'ch': 'ch value' } region_choice = list(regions.items()) part = forms.choicefield(label='', choices=region_choice, required=true)

layout:

self.helper.layout = layout( field('request', placeholder='begin value...'), field('region'), submit("submit", "submit"), html('<a href="{% url \'rush\' %}" class="btn btn-primary btn-md right">rush history</a>') )

how can select default value input?

you need default parameter in field attributes, set value. sample:

region = forms.choicefield(default='us')

django-crispy-forms

No comments:

Post a Comment