mirror of
https://github.com/graphql-python/graphene-django.git
synced 2025-07-13 01:32:24 +03:00
fix datetime type does get converted to a string
to_representation will convert the datetime field into a string representation. However the to_representation on the method field will only call its underlying method.
This commit is contained in:
parent
23efdb8489
commit
e33a6002bf
|
@ -137,5 +137,13 @@ class SerializerMutation(ClientIDMutation):
|
|||
@classmethod
|
||||
def perform_mutate(cls, serializer, info):
|
||||
obj = serializer.save()
|
||||
kwargs = serializer.to_representation(obj)
|
||||
|
||||
kwargs = {}
|
||||
for f, field in serializer.fields.items():
|
||||
if not field.write_only:
|
||||
if isinstance(field, serializers.SerializerMethodField):
|
||||
kwargs[f] = field.to_representation(obj)
|
||||
else:
|
||||
kwargs[f] = field.get_attribute(obj)
|
||||
|
||||
return cls(errors=None, **kwargs)
|
||||
|
|
Loading…
Reference in New Issue
Block a user