select default option django form

from django import forms

class MyForm(forms.Form): OPTIONS = ( ('option1', 'Option 1'), ('option2', 'Option 2'), ('option3', 'Option 3'), ) my_field = forms.ChoiceField(choices=OPTIONS, initial='option2', widget=forms.Select())

Explanation: - Import the forms module from django - Create a class MyForm that inherits from forms.Form - Define a tuple of tuples named OPTIONS containing the options as the first element and their display names as the second element - Define a field my_field as a ChoiceField with choices set to OPTIONS, initial value set to 'option2', and using a Select widget