Skip to content

Commit 2359d39

Browse files
Add docs note re generated BooleanField being required=False (#5665)
* Note that BooleanField default is required=False Closes #5664
1 parent 791539a commit 2359d39

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

docs/api-guide/fields.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ A boolean representation.
124124

125125
When using HTML encoded form input be aware that omitting a value will always be treated as setting a field to `False`, even if it has a `default=True` option specified. This is because HTML checkbox inputs represent the unchecked state by omitting the value, so REST framework treats omission as if it is an empty checkbox input.
126126

127+
Note that default `BooleanField` instances will be generated with a `required=False` option (since Django `models.BooleanField` is always `blank=True`). If you want to change this behaviour explicitly declare the `BooleanField` on the serializer class.
128+
127129
Corresponds to `django.db.models.fields.BooleanField`.
128130

129131
**Signature:** `BooleanField()`

0 commit comments

Comments
 (0)