Customize radioselect default renderer
I have the following form with radioselect options :
jobStatus = forms.ChoiceField( widget=forms.RadioSelect())
However, it renders the radio buttons in <ul> <li> .. &开发者_JS百科lt;/li></ul>
tags.
Could you suggest me any way to render the only radiobutton input ?
Thanks
This is a nice how-to for overriding the renderer of the radio select widget.
https://wikis.utexas.edu/display/~bm6432/Django-Modifying+RadioSelect+Widget+to+have+horizontal+buttons
Basically, create a class that inherits from the forms.RadioFieldRenderer class and override the render method. Then in your form when setting the widget use the renderer argument to set the renderer to your custom renderer class.
That being said, I usually just change the appearance using CSS
精彩评论