Commit c54a557a authored by Lars Kruse's avatar Lars Kruse

GestaltOrAnonSerializer: prepare input data for 'run_validators'

The "run_validators" method of rest_framework.serializers.Serializer
seems to expect a dict. Thus deserialization ("to_internal_value")
fails, since it returns a proper "Gestalt" instance (which cannot be
handled by "run_validators").
parent 13a823a0
Pipeline #1281 failed with stage
in 1 minute and 41 seconds
......@@ -35,6 +35,12 @@ class GestaltOrAnonSerializer(serializers.Serializer):
# todo validate name if no valid id was provided
return data
def run_validators(self, value):
""" the 'run_validators' method of serializers.Serializer seems to expect a dict """
if not isinstance(value, dict):
value = {'id': value.id, 'name': value.name}
return super().run_validators(value)
class Meta:
fields = ('id', 'name')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment