Defaulting ALL booleans to checkboxes in model forms

Hey,

So I have a bunch of form created (model forms), and now it looks like we want checkboxes for all after all. Oups.

So I know I can use the widgets = {'fieldname':CheckboxInput()} (explicitly specify the fields in the form definition). However that’s quite a number of fields to specify this way, only to turn them into the oh-so-desired checkboxes.

Is there anyway in a django project to set CheckboxInput as the default display for all the Boolean fields in my models that end up in a form? Most of my forms are ModelForms, if that helps. Or I guess more generally, override the default input type for a given model field type in a project.

A second best option would be to be able to specify the input at the Model level for my booleans fields - that would make for quicker find & replace in my models, easier to check, and also some fields end up in more than one form so that would still cut things down to a more manageable and less irritating piece of work…

Thanks.

According to Form fields | Django documentation | Django, the default for a BooleanField is a checkbox. What is making you think otherwise?

The fact that most of the data I had to import had missing info, so I had imported it allowing null=True.

Thus in that case the default isn’t apparently a checkbox, but a dropdown (to allow for the unknown/missing data).

A bit of a facepalm on that I guess.

Yes, a NullBooleanField is different.