ChoiceField get choice value in template

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="{{}}" {% if forloop.counter0 == 0 %}checked="checked"{% endif %}>
    <label class="form-check-label" for="{{radio.id_for_label}}">{{radio.choice_label}}</label>

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:

  1. {{radio}} ← result from {% for radio in gameInfoForm.show_game %}
  2. {{form}} ← ModelForm type

The “Django way” of doing it would be to create a custom template for those elements you want rendered in a specific manner. See How to override templates and Overriding built-in widget templates. (Also on that latter page is some information on the context supplied to the rendering of the widget.)

You can learn a lot by reading the built-in templates to see how they construct the widgets. The Django Debug Toolbar also presents a lot of information about how a page is constructed and rendered.

[Late Edit] Also see RadioSelect

oh okay. thank you for the links. I’ll get back when I have the solution