How can I declare the initial value of the switch?
form.py
YESNO = ( ('Yes','Yes'), ('No', 'No'), ) class MyForm(forms.Form): like = forms.ChoiceField(widget=forms.RadioSelect, choices=YESNO)
myhtml.html
{{form.like}}
I am trying to put:
like = forms.ChoiceField(widget=forms.RadioSelect, choices=YESNO, initial={'Yes':'Yes'})
when I run my code, my radio button is not selected yet.
gadss
source share