aboutsummaryrefslogtreecommitdiffstats
path: root/docs/topics
diff options
context:
space:
mode:
Diffstat (limited to 'docs/topics')
-rw-r--r--docs/topics/2.2-release-notes.md8
1 files changed, 7 insertions, 1 deletions
diff --git a/docs/topics/2.2-release-notes.md b/docs/topics/2.2-release-notes.md
index ab1ab0c5..be9c8ab0 100644
--- a/docs/topics/2.2-release-notes.md
+++ b/docs/topics/2.2-release-notes.md
@@ -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`.