mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-02-02 20:54:42 +03:00
Tweaks to release notes.
This commit is contained in:
parent
691a8f682d
commit
cc2ec2bbf0
|
@ -77,6 +77,10 @@ The implicit to-many behavior on serializers, and the `ManyRelatedField` style c
|
|||
|
||||
Serializer relationships for nullable Foreign Keys will change from using the current `null=True` flag, to instead using `required=False`.
|
||||
|
||||
For example, is a user account has an optional foreign key to a company, that you want to express using a hyperlink, you might use the following field in a `Serializer` class:
|
||||
|
||||
current_company = serializers.HyperlinkedRelatedField(required=False)
|
||||
|
||||
This is in line both with the rest of the serializer fields API, and with Django's `Form` and `ModelForm` API.
|
||||
|
||||
Using `required` throughout the serializers API means you won't need to consider if a particular field should take `blank` or `null` arguments instead of `required`, and also means there will be more consistent behavior for how fields are treated when they are not present in the incoming data.
|
||||
|
@ -87,7 +91,9 @@ The `null=True` argument will continue to function, and will imply `required=Fal
|
|||
|
||||
The `CharField` API previously took an optional `blank=True` argument, which was intended to differentiate between null CharField input, and blank CharField input.
|
||||
|
||||
In keeping with Django's CharField API, REST framework's `CharField` will only ever return the empty string, for missing or `None` inputs. The `blank` flag will no longer be in use, and you should instead just use the `required=<bool>` flag.
|
||||
In keeping with Django's CharField API, REST framework's `CharField` will only ever return the empty string, for missing or `None` inputs. The `blank` flag will no longer be in use, and you should instead just use the `required=<bool>` flag. For example:
|
||||
|
||||
extra_details = CharField(required=False)
|
||||
|
||||
The `blank` keyword argument will continue to function, but will raise a `PendingDeprecationWarning`.
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user