django form radio input layout

前端 未结 4 881
醉话见心
醉话见心 2021-01-02 17:05

What is the \"djangoy\" way to approach this problem:

In my form class, I have a forms.ChoiceField whose widget is a forms.RadioSelect widget, one of whose choices n

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-02 17:45

    If I understand your problem correctly, you can access choices tuple in template:

      {# Assuming {{ field }} here is {{ form.rad }} #} {% for choice in field.field.choices %}
    • {% endfor %}

提交回复
热议问题