Django Unit Test Fail, когда я тестирую UpdateView

В моем проекте есть UserUpdateView, который выглядит следующим образом:

class UserUpdateView(AuthenticationMixin, AuthorizationMixin, SuccessMessageMixin, UpdateView):

'''Update User info(username, full/second name, password)'''

    model = User
    form_class = UserForm
    template_name = 'form.html'
    permission_denied_message = _("You can't change this profile, this is not you")
    permission_denied_url = reverse_lazy('users-detail')
    success_message = _('User Profile is successfully changed')
    success_url = reverse_lazy('users-detail')
    extra_content = {
        'title': _('Update user'),
        'button_text': _('Update'),
    }

Модель пользователя выглядит следующим образом:

class User(AbstractUser):
first_name = models.CharField(max_length=150)
last_name = models.CharField(max_length=150)

    def __str__(self):
        return self.get_full_name()

И тест для UserUpdateView:

class UpdateUserTest(TestCase):
    def setUp(self):
        self.client = Client()
        self.user = User.objects.create(username='tota123', first_name='Andrey', last_name='Totavich', password='lexA456132')

    def test_update_user(self):
        
        self.client.login(username='tota123', password='lexA456132')
        
        response = self.client.post(
            reverse('user-update', kwargs={'pk': self.user.pk}),{
                'username': 'tota321',
                'first_name': 'Sergey',
                'last_name': 'Simo',
                'password1': 'lexA456132',
                'password2': 'lexA456132'
            })
        
        self.assertEqual(response.status_code, 302)  # Redirect after successful update
        self.assertEqual(self.user.username, 'tota321')

Результат тестов:

self.assertEqual(self.user.username, 'tota321')
AssertionError: 'tota123' != 'tota321'
- tota123
?      --
+ tota321
?     ++

Как решить

эту проблему и почему модель пользователя не меняется? Когда я запускаю свой проект локально - я могу изменить информацию о пользователе, и это работает, UserUpdateView работает правильно. Чего мне не хватает?
Вернуться на верх