Note that BooleanField default is required=False

Closes #5664
This commit is contained in:
Carlton Gibson 2017-12-13 12:27:15 +01:00
parent 1692feb535
commit f238ce6606

View File

@ -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.
Note that default `BooleanField` instances will be generated with a `required=False` option (since Django `models.BooleanField` is always `blank=True`). For JSON-only APIs you may wish explicitly declare BooleanFields in order to control this.
Corresponds to `django.db.models.fields.BooleanField`.
**Signature:** `BooleanField()`
@ -682,3 +684,4 @@ The [django-rest-framework-hstore][django-rest-framework-hstore] package provide
[django-rest-framework-hstore]: https://github.com/djangonauts/django-rest-framework-hstore
[django-hstore]: https://github.com/djangonauts/django-hstore
[python-decimal-rounding-modes]: https://docs.python.org/3/library/decimal.html#rounding-modes
[required-by-default-boolean-field]: http://notes.noumenal.es/2017/12/13/required-by-default.html