Custom rendering a radioselect in django form / accessing single element?

Posted by Oli on Stack Overflow See other posts from Stack Overflow or by Oli
Published on 2010-06-07T13:28:17Z Indexed on 2010/06/07 13:32 UTC
Read the original article Hit count: 267

Filed under:

I have a form like this:

CHOICES = [  
           ('a', 'a_value'),  
           ('b', 'b_value'),  
           ('c', 'c_value')  
]  

self.fields["choice"] = forms.ChoiceField(  
    widget=RadioSelect(),  
    choices=CHOICES,   
)  

How can I select a single element of this form field in my template? I want to be able to do something like:

<tr><td>{{form.choice.a}}</td><td>some custom extra field</td></tr>

Or is there another way to change how the RadioSelect is rendered?

© Stack Overflow or respective owner

Related posts about django-forms