Skip to content

Commit

Permalink
Re-order allow_null and default in field docs
Browse files Browse the repository at this point in the history
default is prior to allow_null. allow_null implies an outgoing default=None.
  • Loading branch information
carltongibson committed Mar 20, 2018
1 parent acd53cf commit 9252a37
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions docs/api-guide/fields.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,6 @@ Setting this to `False` also allows the object attribute or dictionary key to be

Defaults to `True`.

### `allow_null`

Normally an error will be raised if `None` is passed to a serializer field. Set this keyword argument to `True` if `None` should be considered a valid value.

Note that setting this argument to `True` will imply a default value of `null` for serialization output, but does not imply a default for input deserialization.

Defaults to `False`

### `default`

If set, this gives the default value that will be used for the field if no input value is supplied. If not set the default behaviour is to not populate the attribute at all.
Expand All @@ -61,6 +53,14 @@ When serializing the instance, default will be used if the the object attribute

Note that setting a `default` value implies that the field is not required. Including both the `default` and `required` keyword arguments is invalid and will raise an error.

### `allow_null`

Normally an error will be raised if `None` is passed to a serializer field. Set this keyword argument to `True` if `None` should be considered a valid value.

Note that setting this argument to `True` will imply a default value of `null` for serialization output, but does not imply a default for input deserialization.

Defaults to `False`

### `source`

The name of the attribute that will be used to populate the field. May be a method that only takes a `self` argument, such as `URLField(source='get_absolute_url')`, or may use dotted notation to traverse attributes, such as `EmailField(source='user.email')`. When serializing fields with dotted notation, it may be necessary to provide a `default` value if any object is not present or is empty during attribute traversal.
Expand Down

0 comments on commit 9252a37

Please sign in to comment.