I have a template:
...
<form action="/reportform/" method="post">
<p><label>Aircraft system:</label>
<br>{{ Querry.system }}
...
it looks like this
How can I set a Size option for this box? for example, 10.
Use the attrs attribute to define the size.
class MyForm(forms.Form):
system = forms.ChoiceField(choices=SYSTEM_CHOICES,
widget=forms.SelectMultiple(attrs={'size':'40'}))
Sometimes, it is useful to override the widget in the forms init method.
class MyForm(forms.Form):
<snip>
def __init__(self, *args, **kwargs):
super(MyForm, self).__init__(*args, **kwargs)
self.fields['system'].widget = forms.SelectMultiple(attrs={'size':'40'}))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With