mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-04-28 13:03:45 +03:00
Add docs note re generated BooleanField being required=False
(#5665)
* Note that BooleanField default is required=False Closes #5664
This commit is contained in:
parent
791539acec
commit
2359d3981b
|
@ -124,6 +124,8 @@ A boolean representation.
|
||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
Corresponds to `django.db.models.fields.BooleanField`.
|
Corresponds to `django.db.models.fields.BooleanField`.
|
||||||
|
|
||||||
**Signature:** `BooleanField()`
|
**Signature:** `BooleanField()`
|
||||||
|
|
Loading…
Reference in New Issue
Block a user