@dataclass
class Person():
name: str
class PersonSerializer(DataclassSerializer):
class Meta:
dataclass = Person
When I have my json data from the client, I can serialize it with serialized_data = PersonSerializer(data={'name':'alice'}). However, if I call is_valid() and then validated_data, this will give me an OrderedDict, instead of a Person object. Am I missing something obvious, or do I just have to call Person(**serialized_data) to get it back to my Person dataclass?
Hi, given the following:
When I have my json data from the client, I can serialize it with
serialized_data = PersonSerializer(data={'name':'alice'})
. However, if I callis_valid()
and thenvalidated_data
, this will give me anOrderedDict
, instead of aPerson
object. Am I missing something obvious, or do I just have to callPerson(**serialized_data)
to get it back to myPerson
dataclass?