first commit
This commit is contained in:
commit
3e4574dcdd
163 files changed
+3559
No files matched your search
@@ -0,0 +1,18 @@
|
||||
from rest_framework import serializers
|
||||
|
||||
|
||||
def create_serializer_class(name, fields):
|
||||
return type(name, (serializers.Serializer,), fields)
|
||||
|
||||
|
||||
def inline_serializer(*, fields, data=None, **kwargs):
|
||||
# Important note if you are using `drf-spectacular`
|
||||
# Please refer to the following issue:
|
||||
# https://github.com/HackSoftware/Django-Styleguide/issues/105#issuecomment-1669468898
|
||||
# Since you might need to use unique names (uuids) for each inline serializer
|
||||
serializer_class = create_serializer_class(name="inline_serializer", fields=fields)
|
||||
|
||||
if data is not None:
|
||||
return serializer_class(data=data, **kwargs)
|
||||
|
||||
return serializer_class(**kwargs)
|
||||
Reference in new issue
Block a user