Django form 'autocomplete' = 'off' does not work

I saw a lot of answers on SO, and none of them work in my case. My model is as follows:

class ChangePasswordForm(forms.Form):
    current_password = forms.CharField(
        max_length=64,
        widget=forms.PasswordInput(
            attrs={'placeholder': 'Current Password', 'autocomplete': 'off'}))

    new_password = forms.CharField(
        min_length=6,
        max_length=64,
        widget=forms.PasswordInput(
            attrs={'placeholder': 'New Password', 'autocomplete': 'off'}))

    confirm_password = forms.CharField(
        min_length=6,
        max_length=64,
        widget=forms.PasswordInput(
            attrs={'placeholder': 'Confirm New Password', 'autocomplete': 'off'}))

The form fills all current_fields, new_password and confirm_password. I checked Safari and Google Chrome and I still have the same problem. Can someone tell me what I am doing wrong?

+4
source share
2 answers

In modern browsers, I do not believe that you can achieve what you are looking for. According to the Mozilla Developer Network ,

... many modern browsers do not support autocomplete = "off" for input fields.

  • autocomplete = "off" , , , , , , .
  • autocomplete = "off" , , , .

Firefox ( 38), Google Chrome ( 34) Internet Explorer ( 11).

+1

, "off" "new-password" /widget/attrs/autocomplete. .

EX:

current_password = forms.CharField(
    max_length=64,
    widget=forms.PasswordInput(
        attrs={'placeholder': 'Current Password', 'autocomplete': 'new-password'}))

0

Source: https://habr.com/ru/post/1611513/


All Articles