forms - Radiobutton in instances of Django ModelChoiceField -


i trying manually render modelchoicefield instances in template. working ok, not able add radio button in last cell. how do add radio button ?

forms.py:

class submissionform(forms.form):       name = forms.charfield(max_length=100)       spl_candidates = forms.modelchoicefield(queryset=candidate.objects.filter(category="spl"),                                         widget=forms.radioselect,                                         empty_label=none) 

template

    <table>         {% data in form.spl_candidates.field.queryset %}         <tr>             <td>                 {{ data.name }}             </td>             <td>                 {{ data.description }}             </td>             <td>              </td>         </tr>         {% endfor %}     </table> 

add custom html radio button achieve this,

in template this,

    <table>     {% data in form.spl_candidates.field.queryset %}     <tr>         <td>             {{ data.name }}         </td>         <td>             {{ data.description }}         </td>         <td>             <input type="radio" name="{{ data.name }}" value="{{ data.desc }}">         </td>     </tr>     {% endfor %} </table> 

Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -