user_management/api/serializers.py
def update(self, instance, validated_data):
        """Check the old password is valid and set the new password."""
        if not instance.check_password(validated_data['old_password']):
            msg = _('Invalid password.')
            raise serializers.ValidationError({'old_password': msg})

        instance.set_password(validated_data['new_password'])
        instance.save()
        return instance
def update(self, instance, validated_data):
        """Check the old password is valid and set the new password."""
        if not instance.check_password(validated_data['old_password']):
            msg = _('Invalid password.')
            raise serializers.ValidationError({'old_password': msg})

        instance.set_password(validated_data['new_password'])
        instance.save()
        return instance
Check the old password is valid and set the new password.