I have a radio button which is a yes / no.
YES_NO_CHOICES = [(False,'No'),(True,'Yes')]
I also have a choicefield in my ModelForm
show_game = forms.ChoiceField(widget=forms.RadioSelect, choices=YES_NO_CHOICES, required=True)
I dislike the HTML provided by Django; hence, I made a custom html with css which looks like this:
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="id_show_game" id="{{radio.id_for_label}}" value="{{radio.id}}" {% if forloop.counter0 == 0 %}checked="checked"{% endif %}>
<label class="form-check-label" for="{{radio.id_for_label}}">{{radio.choice_label}}</label>
</div>
However, value
is appearing empty:
How do I access the value
of radio
which is a ChoiceField WITHOUT using the template provided by Django in the following tags:
-
{{radio}}
← result from{% for radio in gameInfoForm.show_game %}
-
{{form}}
← ModelForm type