Added create python object class from serializer data.
nxexox opened this issue · 0 comments
nxexox commented
Added python class objects from serializer data.
Example:
from rest_framework import serializers
class ExampleObject(object):
field_one = 10
def __str__(self):
return 'ExampleObject(field_one={})'.format(self.field_one)
class ExampleObjectSerializer(serializers.Serializer):
class Meta:
to_object = ExampleObject
ser = ExampleObjectSerializer(data={'field_one': 100})
ser.is_valid()
obj = ser.get_object()
print(obj)
# 'ExampleObject(field_one=100)'