复制代码def validate(self, attrs): if attrs['password'] != attrs['repeated']: raise serializers.ValidationError("passwords do not match!") return attrs