John Patrick
John Patrick

Reputation: 43

How to add CSS class to django RadioSelect label?

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>

Upvotes: 0

Views: 826

Answers (1)

John Patrick
John Patrick

Reputation: 43

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...

Upvotes: 2

Related Questions