Django forms.PasswordInput() updated my application main password

On my Django app, I have a custom field rendered with the forms.PasswordInput() widget. This works as expected from a visual perspective. However, Chrome detects this as a password and then updates this field with the master password that a user might have set on his account on the app. Is there a way to get a forms.PasswordInput() field without Chrome messing passwords fields in it?

You must add autocomplete="off" to your password input, either in html like this:

<input name="password" type="password" autocomplete="off"/>

or in your forms.py like this:

password = forms.PasswordInput(attrs={"autocomplete":"off"})

More information can be found in Mozilla documentation about this topic.

Edit

This is working in my outdated Chrome version but is not supported in most recent versions. You can try the hack described here but I'd rather go with Javascript to reset the form. Below is a jQuery example:

$(() => { // document.ready : wait dom to be loaded
    $('[name=password]').val("") // reset value
})
Back to Top