Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make BooleanField display a larger checkbox in Django

So I am creating a website using Django templates, forms etc. One thing I've noticed though is that the checkboxes I create via BooleanFields are too small. Any idea how to make the thing bigger?

like image 328
Carlo Chum Avatar asked Apr 05 '12 05:04

Carlo Chum


2 Answers

You can try doing this using css, but the thing is very difficult: http://www.456bereastreet.com/lab/form_controls/checkboxes/

When you create a class in css you can add it to your input using widgets, something like:

field = forms.BooleanField(widget=forms.CheckboxInput(attrs={'class':'your_class'}))
like image 175
szaman Avatar answered Sep 21 '22 00:09

szaman


I found below is easier and works for me:

class Meta:
        ...
        widgets = {
            'my_checkbox': forms.CheckboxInput(attrs={'style':'width:20px;height:20px;'}),
        }
like image 43
Gido Avatar answered Sep 21 '22 00:09

Gido