mirror of
https://github.com/HackSoftware/Django-Styleguide.git
synced 2024-11-24 18:43:46 +03:00
12 lines
347 B
Python
12 lines
347 B
Python
def create_serializer_class(name, fields):
|
|
return type(name, (serializers.Serializer, ), fields)
|
|
|
|
|
|
def inline_serializer(*, fields, data=None, **kwargs):
|
|
serializer_class = create_serializer_class(name='', fields=fields)
|
|
|
|
if data is not None:
|
|
return serializer_class(data=data, **kwargs)
|
|
|
|
return serializer_class(**kwargs)
|