Take the 2-minute tour ×

I have a Django form, and I want the help_text for a ChoiceField to display immediately after the options, without a newline between them. Here's the code for my form:

class SettingsForm(forms.Form):
   skin = forms.ChoiceField(choices = skin.SKINS2,
      help_text="this alters how the website looks")
   #...other fields...

Django produces this HTML:

<li><label for="id_skin_0"><input checked="checked" type="radio" id="id_skin_0"
value="main" name="skin" /> main</label></li> 
<li><label for="id_skin_1"><input type="radio" id="id_skin_1" value="bubble"
name="skin" /> bubble</label></li> 
</ul><br />this alters how the website looks

The problem with this is that when it displays, there is a line between the option radio buttons and the help text (note the <br /> immediately before the help_text).

How do I remove the <br />, or otherwise force the help_text to appear immediately below the radio buttons?

share|improve this question
add comment

1 Answer

Instead of help_text did you try using the label parameter?

If none of those work for you then just break down and put the HTML the way you want in your template. I end up doing that anyway on all but the simplest of forms.

share|improve this answer
I've (just now) tried using the label parameter instead of help_text, and it puts the text to the left of the radio buttons instead of below them. Maybe I could use CSS to shrink the size of the <br> to nothing? or perhaps a better solution would be for me to subclass the forms.Form class (another thing I'd like to do is put the help_text within a <span class='help_text'> –  Phil Hunt Mar 23 '11 at 14:09
I know I could just use HTML; I'd really rather not do that, since using Forms is neater and easier to maintain once the form gets bigger. But it may come to that. –  Phil Hunt Mar 23 '11 at 14:11
Yeah, sorry I don't have any more things to try. When it comes down to it, those form.as_p, as_table, as_ul are great shortcuts, but most of the time I end up having to customize them. I usually do a form.as_p once to get the output, then I copy and modify that to my liking. –  Brian Neal Mar 23 '11 at 16:17
add comment

Your Answer


