Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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> .. </li></ul> tags.

Could you suggest me any way to render the only radiobutton input ?

Thanks

like image 361
brsbilgic Avatar asked May 25 '11 19:05

brsbilgic


1 Answers

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

like image 152
dting Avatar answered Sep 22 '22 08:09

dting