views:

29

answers:

0

I have a Django (1.1) form. One of the fields is CharField with a set number of choices, this is correctly rendered as a <select> box. However the html style attribute for the <select> is set as …style="width: 100px"…. I want to conserve screen space, so I want to change this to style="width: auto", or even just remove the style attribute.

However I tried this (in the form definition):

my_form_field = forms.MultipleChoiceField(choices=CHOICES, widget=forms.Select(attrs={'style':'width: auto;'}))

and that doesn't work, the style is still set as width:100px. How change the style of the widgets?

UPDATE: This form is rendered in a normal page. I am iterating over the fields manually and calling {{ form.my_form_field }}