brsbilgic
brsbilgic

Reputation: 11833

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

Upvotes: 5

Views: 3248

Answers (1)

dting
dting

Reputation: 39287

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

Upvotes: 8

Related Questions