views:

42

answers:

1

Anyway to access the widget/render a specific choice from a ChoiceField?

APPROVAL_CHOICES = (
    ('true', 'Approve'),
    ('false', 'Re-Submit')
)

class ProofApprovalForm(forms.Form):
    approved = forms.ChoiceField(
        choices=APPROVAL_CHOICES, 
        widget=forms.widgets.RadioSelect
    )

Would like to access the choices in the template separately.

{{ form.approved.choices.true }}

Would render the true widget <input type="radio" value="true" name="approved_0" />...

I could render them manually, but want to see if there is a cleaner pythonic/django way of handling this situation.

A: 

Only to create your own widget or field with overloaded render() method

Dmitry Shevchenko