Skip to content

Commit edcbd9e

Browse files
committed
Add release notes for #5888
1 parent 68410eb commit edcbd9e

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

docs/topics/release-notes.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,26 @@ You can determine your currently installed version using `pip show`:
5656
serializer.save(owner=self.request.user)
5757

5858
Alternatively you may override `save()` or `create()` or `update()` on the serialiser as appropriate.
59+
* Correct allow_null behaviour when required=False [#5888][gh5888]
60+
61+
Without an explicit `default`, `allow_null` implies a default of `null` for outgoing serialisation. Previously such
62+
fields were being skipped when read-only or otherwise not required.
63+
64+
**Possible backwards compatibility break** if you were relying on such fields being excluded from the outgoing
65+
representation. In order to restore the old behaviour you can override `data` to exclude the field when `None`.
66+
67+
For example:
68+
69+
@property
70+
def data(self):
71+
"""
72+
Drop `maybe_none` field if None.
73+
"""
74+
data = super().data()
75+
if 'maybe_none' in data and data['maybe_none'] is None:
76+
del data['maybe_none']
77+
return data
78+
5979
* Refactor dynamic route generation and improve viewset action introspectibility. [#5705][gh5705]
6080

6181
`ViewSet`s have been provided with new attributes and methods that allow
@@ -1820,6 +1840,7 @@ For older release notes, [please see the version 2.x documentation][old-release-
18201840

18211841
<!-- 3.8.0 -->
18221842
[gh5886]: https://github.com/encode/django-rest-framework/issues/5886
1843+
[gh5888]: https://github.com/encode/django-rest-framework/issues/5888
18231844
[gh5705]: https://github.com/encode/django-rest-framework/issues/5705
18241845
[gh5796]: https://github.com/encode/django-rest-framework/issues/5796
18251846
[gh5763]: https://github.com/encode/django-rest-framework/issues/5763

0 commit comments

Comments
 (0)