При обновлении юзера, мне выдает ошибку:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.9/site-packages/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/local/lib/python3.9/contextlib.py", line 79, in inner
    return func(*args, **kwds)
  File "/usr/local/lib/python3.9/site-packages/django/db/transaction.py", line 290, in __exit__
    connection.set_autocommit(True)
  File "/usr/local/lib/python3.9/site-packages/django/db/backends/base/base.py", line 431, in set_autocommit
    self.run_and_clear_commit_hooks()
  File "/usr/local/lib/python3.9/site-packages/django/db/backends/base/base.py", line 664, in run_and_clear_commit_hooks
    func()
  File "/app/authentication/api/users.py", line 275, in <lambda>
    transaction.on_commit(lambda: self._send_email_verification(self.request.user))
  File "/app/authentication/api/users.py", line 259, in _send_email_verification
    res = ResendEmailVerificationView.as_view()(request._request, *args, **kwargs)

Exception Type: AttributeError at /user/user-update/
Exception Value: 'CustomUser' object has no attribute '_request'

Вот мое представление:

class UserUpdateApi(generics.UpdateAPIView):
    serializer_class = UserUpdateSerializer

    def get_object(self):
        return self.request.user

    def _send_sms(self, request, *args, **kwargs):
        res = SendOrResendSMSAPIView.as_view()(request._request, *args, **kwargs)
        return res.status_code == 200

    def _send_email_verification(self, request, *args, **kwargs):
        res = ResendEmailVerificationView.as_view()(request._request, *args, **kwargs)
        return res.status_code == 200

    def _send_verification_messages(self, email, phone, *args, **kwargs):
        response_data = {}
        sent_sms = False
        sent_email = False
        email = self.request.data.get("email")
        phone_data = self.request.data.get("phone")
        phone_number = phone_data["phone_number"] if phone_data else None

        if phone_number:
            transaction.on_commit(lambda: self._send_sms(phone_number))
            sent_sms = True

        if email:
            transaction.on_commit(lambda: self._send_email_verification(self.request.user))
            sent_email = True

        if sent_sms and sent_email:
            message = _('Verification e-mail and SMS sent.')
        elif sent_sms:
            message = _('Verification SMS sent.')
        elif sent_email:
            message = _('Verification e-mail sent.')
        else:
            message = _('No verification method specified.')

        response_data['detail'] = message

        return response_data

    def update(self, request, *args, **kwargs):
        response_data = {}
        user = self.get_object()

        phone = user.phone if hasattr(user, 'phone') else None
        email = request.data.get('email', None)

        serializer = self.get_serializer(user, data=request.data, partial=True)
        serializer.is_valid(raise_exception=True)

        self.perform_update(serializer)

        response_data.update(self._send_verification_messages(request, email, phone, *args, **kwargs))

        return Response({**serializer.data, **response_data}, status=status.HTTP_200_OK)


Вот моя модель юзера:

class CustomUser(AbstractUser):
    APPLICANT = "Applicant"
    EMPLOYER = "Employer"
    ROLE_CHOICES = (
        (APPLICANT, "Applicant"),
        (EMPLOYER, "Employer"),
    )
    username = models.CharField(max_length=255, unique=True, blank=True, null=True)
    email = models.EmailField(_("email address"), unique=False, max_length=254, blank=True,null=True)
    role = models.CharField(max_length=50, choices=ROLE_CHOICES)
    avatar = models.ImageField(_("avatar"), upload_to="avatars/", null=True, blank=True)
    is_staff = models.BooleanField(default=False)
    is_active = models.BooleanField(default=True)
    created_date = models.DateTimeField(auto_now_add=True)
    updated_date = models.DateTimeField(auto_now=True)
    blocked_until = models.DateTimeField(null=True, blank=True)
    USERNAME_FIELD = "username"
    REQUIRED_FIELDS = []

    objects = UserManager()

    def __str__(self):
        return self.email

    @property
    def fullname(self):
        return f"{self.first_name} {self.last_name}"
        
        
Вот модель телефона: 

class PhoneNumber(models.Model):
    id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
    user = models.OneToOneField(CustomUser, related_name='phone', on_delete=models.CASCADE)
    phone_number = PhoneNumberField(unique=True)
    security_code = models.CharField(max_length=120)
    is_verified = models.BooleanField(default=False)
    sent = models.DateTimeField(null=True)
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

    class Meta:
        ordering = ('-created_at', )

    def __str__(self):
        return self.phone_number.as_e164

    def generate_security_code(self):
        """
        Returns a unique random `security_code` for given `TOKEN_LENGTH` in the settings.
        Default token length = 6
        """
        token_length = getattr(base, "TOKEN_LENGTH", 6)
        return get_random_string(token_length, allowed_chars="0123456789")

    def is_security_code_expired(self):
        expiration_date = self.sent + datetime.timedelta(
            minutes=base.TOKEN_EXPIRE_MINUTES
        )
        return expiration_date <= timezone.now()

    def send_confirmation(self):
        twilio_account_sid = base.TWILIO_ACCOUNT_SID
        twilio_auth_token = base.TWILIO_AUTH_TOKEN
        twilio_phone_number = base.TWILIO_PHONE_NUMBER

        self.security_code = self.generate_security_code()

        # print(
        #     f'Sending security code {self.security_code} to phone {self.phone_number}')

        if all(
            [
                twilio_account_sid,
                twilio_auth_token,
                twilio_phone_number
            ]
        ):
            try:
                twilio_client = Client(
                    twilio_account_sid, twilio_auth_token
                )
                twilio_client.messages.create(
                    body=f'Your activation code is {self.security_code}',
                    to=str(self.phone_number),
                    from_=twilio_phone_number,
                )
                self.sent = timezone.now()
                self.save()
                return True
            except TwilioRestException as e:
                print(e)
        else:
            print("Twilio credentials are not set")

    def check_verification(self, security_code):
        if (
            not self.is_security_code_expired() and
            security_code == self.security_code and
            self.is_verified == False
        ):
            self.is_verified = True
            self.save()
        else:
            raise NotAcceptable(
                _("Your security code is wrong, expired or this phone is verified before."))

        return self.is_verified

Вот мой сериализатор:

class UserUpdateSerializer(serializers.ModelSerializer):
    phone = PhoneNumberUpdateSerializer()

    class Meta:
        model = CustomUser
        fields = ('email', 'first_name', 'last_name', 'phone')