How do make help_text in a ChoiceField display immediately below the radio buttons?
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,
开发者_如何学JAVA widget=forms.RadioSelect,
help_text="this alters how the website looks")
#...other fields...
Django produces this HTML:
<ul>
<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?
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.
精彩评论