0

how do i add css class for the auto generated label for a RadioSelect widget

<div>
    {% for rdo in form.category_res %}
        <div class="custom-control custom-radio custom-control-inline">
          {{ rdo }}
        </div>  
    {% endfor %}
</div>

1 Answer 1

3

I hope this will help someone in the future.... I rendered my template like this:

{% for choice in form.category_res %}
        <div class="custom-control custom-radio custom-control-inline">
            {{ choice.tag }}
            <label for="{{ choice.id_for_label  }}" class="custom-control-label">{{ choice.choice_label }}</label>
        </div>
{% endfor %}

since I'm using bootstrap, it requires me to add a class to the label for my field with RadioSelect() as a widget for the CSS to work...

Sign up to request clarification or add additional context in comments.

1 Comment

great, still works in 2025 with Django 5.2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.