File tree Expand file tree Collapse file tree 2 files changed +410
-1
lines changed
Expand file tree Collapse file tree 2 files changed +410
-1
lines changed Original file line number Diff line number Diff line change @@ -211,6 +211,31 @@ print(user.profile.access_key.key)
211211Note: The same value will be used for all nested instances like default value but with higher priority.
212212
213213
214+ New-Style Serializers
215+ ================
216+
217+ In 2020, an enhanced set of mixins were added that permit fine-grained control of nested
218+ Serializer behavior using a ` match_on ` argument. New-style serializers delegate control
219+ of the Create/Update behavior to the nested Serializer. The parent Serializer need only
220+ resolve nested serializers in the right order; this is handled by the ` RelatedSaveMixin ` .
221+
222+ New-style Serializers provide the following semantics:
223+
224+ - Get: retrieve a matching object (but DO NOT update)
225+ - Update: retrieve and update a matching object
226+ - Create: create an object using the entire payload
227+ - Combinations of the above e.g. GetOrCreate and UpdateOrCreate
228+
229+ The matching of ` data ` to a specific ` instance ` is driven by a list of fields found in
230+ ` match_on ` . This value is obtained from:
231+
232+ - the ` match_on ` kwarg provided when the field is initialized
233+ - the DEFAULT_MATCH_ON class attribute
234+
235+ The new-style Serializers may be used as top-level Serializers to provide get-or-create
236+ behaviors to DRF endpoints. Examples of use can be found in
237+ ` test_nested_serializer_mixins.py ` .
238+
214239Known problems with solutions
215240=============================
216241
You can’t perform that action at this time.
0 commit comments