From 9a4f4ee17cdee7666206bf637f5e7d8f796ffa2d Mon Sep 17 00:00:00 2001 From: Santiago Lamora Date: Thu, 7 Oct 2021 14:11:50 +0200 Subject: [PATCH] Fix SetPasswordHyperlinkedSerializer (update to new DRF) --- orchestra/api/serializers.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/orchestra/api/serializers.py b/orchestra/api/serializers.py index 577784f5..01005771 100644 --- a/orchestra/api/serializers.py +++ b/orchestra/api/serializers.py @@ -84,14 +84,14 @@ class SetPasswordHyperlinkedSerializer(HyperlinkedModelSerializer): validators=[validate_password], write_only=True, required=False, style={'widget': widgets.PasswordInput}) - def validate_password(self, attrs, source): + def validate_password(self, value): """ POST only password """ if self.instance: - if 'password' in attrs: + if value: raise serializers.ValidationError(_("Can not set password")) - elif 'password' not in attrs: + elif not value: raise serializers.ValidationError(_("Password required")) - return attrs + return value def validate(self, attrs): """ remove password in case is not a real model field """