How to repair empty string in password from ModelForm?

Good afternoon. I’m new to django, just learning.
I faced such problem: I need to make a user data change page. In the form there is also a field “password” and “confirm_password” for change password. However, when I save the form, the password changes to an empty string. I tried to override the save method, but it does not work as expected - the contents of the password field are deleted in the database.

class ChangeUserForm(forms.ModelForm):

    name = forms.CharField(required=False, label="Имя",
                            widget=forms.TextInput(attrs={'class': 'form-control',
                                                            'placeholder': 'name'}))

    surname = forms.CharField(required=False, label="Фамилия",
                            widget=forms.TextInput(attrs={'class': 'form-control',
                                                            'placeholder': 'surname'}))

    nickname = forms.CharField(required=False, label="Псевдоним",
                            widget=forms.TextInput(attrs={'class': 'form-control',
                                                            'placeholder': 'nickname'}))

    email = forms.EmailField(required=False, label="Адрес электронной почты",
                            widget=forms.EmailInput(attrs={'class': 'form-control',

    address = forms.CharField(required=False, label="Адрес",
                            widget=forms.TextInput(attrs={'class': 'form-control',

    card_id = forms.CharField(required=False, label='Номер банковской карты',
                            widget=forms.TextInput(attrs={'class': 'form-control',
                                                        'placeholder': 'card_id_number'}))

    language = forms.ChoiceField(required=False, label='Язык',
                            choices=(('ua', 'Українська мова'), ('ru', 'Русский язык')),

    sex = forms.ChoiceField(required=False, label='Пол',
                            choices=(('male', 'Мужской пол'), ('female', 'Женский пол')),

    phone_number = forms.CharField(required=False, label='Номер телефона',
                            widget=forms.TextInput(attrs={'class': 'form-control',
                                                        'placeholder': 'phone_number'}))

    town = forms.CharField(required=False, label="Город",
                        widget=forms.TextInput(attrs={'class': 'form-control',

    password = forms.CharField(required=False, label='Пароль',
                        widget=forms.PasswordInput(attrs={'class': 'form-control',
    confirm_password = forms.CharField(required=False, label='Повторите пароль',
                        widget=forms.PasswordInput(attrs={'class': 'form-control',

    def clean_email(self):
        email = self.cleaned_data['email']
        compare_obj = CustomUser.objects.get(email=email)
        if !=
  ['email'] =
            self.add_error('email', f'email {} занят')
        return email


    def clean_confirm_password(self):
        password = self.cleaned_data['password']
        confirm_password = self.cleaned_data['confirm_password']
        if password != confirm_password:
            self.add_error('confirm_password', 'пароли не совпадают')

    def clean_phone_number(self):
        phone = self.cleaned_data['phone_number']
        if phone == "":
  ['phone_number'] = ""
        elif bool("^((\+38\d{10}$)|(38\d{10})|(\d{10})|(\d{9}))$", phone)) is False:
  ['phone_number'] = self.instance.phone_number
            self.add_error('phone_number', 'Введите номер телефона одного из телефонных операторов Украины ') 
            if bool("^\+38\d{10}$", phone)) is True:
            elif bool("^38\d{10}$", phone)) is True: 
                phone = f"+{phone}"
            elif bool("^\d{10}$", phone)) is True: 
                phone = f"+38{phone}"
            elif bool("^\d{9}$", phone)) is True: 
                phone = f"+380{phone}"

        return phone

    def save(self, commit=True):
        user = super(ChangeUserForm, self).save(commit=False)
        password = self.cleaned_data["password"]
        if len(password) == 0:
            del self.cleaned_data['password']
            del self.cleaned_data['confirm_password']
            if commit:
        return user

    class Meta:
        model = CustomUser
        fields = ("name", "surname", "nickname", "email", "address",
                 "card_id", "language",
                 "sex", "town", "phone_number", "born", "password")

        widgets = {
            'born': forms.DateInput(attrs={'class': 'form-control', 'placeholder': 'Select a date','type': 'date'})}

def change_user_data(request):
    message = ''
    if request.method == "POST":       
        form = ChangeUserForm(request.POST, instance=request.user)
        if form.is_valid():

            message = 'Изменения успешно применены!'
        form = ChangeUserForm(instance=request.user)

    return render(request, 'users/change_user_data.html', context={'form': form, 'message': message})

For the second day I have been doing a search in Google and turned to Stackoverflow. But unfortunately I couldn’t solve the problem.
Sorry for bad English, if anything, I’m not a native speaker =)

Hello @thelonggoodbuy!
I’ll be happy to help in anything I can.
I see this code:

I was wondering if you can see the “print” length of the password when you send it, in this line:


If you can see the length of the password, that means the problem is another thing.
Let me know

Are you getting any error messages in the console where you’re running this? (I would expect to see you get a traceback from this.)

Also, are you using a custom user model? If so, can you post that class here?