@Rishab is correct , but I will clarify further, because, at first glance, this does not look like a solution, although it does; or, at least, it can be discarded in order to obtain a useful effect, without diving too deep into the forms of django.
The second element of the tuple is represented inside the "label" tag, so any "inline elements" are allowed; eg:
Desired Result
Or something like this
<ul> <li><label for="id_ticket_0"> <input type="radio" id="id_ticket_0" value="PARTTIME" name="ticket"> <em>Part Time</em> Valid on Friday Night and Saturday Only </label></li> <li><label for="id_ticket_1"> <input type="radio" id="id_ticket_1" value="DAYTIME" name="ticket"> <em>Casual</em> Valid on Saturday Only </label></li> <li><label for="id_ticket_2"> <input type="radio" id="id_ticket_2" value="EARLYBIRD" name="ticket"> <em>Early Bird</em> Valid on Friday, Saturday, and Sunday. $15 discount for booking before 1am January 3rd, 2011 </label></li> </ul>
Simple example
The trick is that "mark_safe" contains the contents of the description, and then all you need is:
from django.utils.safestring import mark_safe choices = ( ('1', mark_safe(u'<em>One</em> | This is the first option. It is awesome')), ('2', mark_safe(u'<em>Two</em> | This is the second option. Good too.')) )
Comprehensive Example
So in this example we are:
- put options into a list (any iterable structure will do)
- pass structure to init form to create our radio parameters on the fly
- use the concept list to create an extended description for each radio parameter
Data Structure: Tickets are my own classes, and they have attributes:
- ticket.code - as in the ticket code
- label - short description
- help - a more detailed description
But more on that later. First, create some instances:
from mymodule import ticket
This probably happened in your view code. Now, to find out what happens in the form
class OrderForm(ModelForm): def __init__(self, *args, **kwargs): self.tickets = kwargs.pop('tickets') super(OrderForm, self).__init__(*args, **kwargs) choices = [(t.code, mark_safe(u'<em>%s</em> %s' % (t.label, t.help))) for t in self.tickets] self.fields['ticket'] = forms.ChoiceField( choices = choices, widget = forms.RadioSelect() )