0

I have a Django ModelForm (with a password input), rendered by the crispy-forms module.

Every time I submit the form, browser asks if it should remember the password.

Anyway it is only a ModelForm (not a LoginForm). How to get rid of this popup?

I found a possible solution here: Disable browser 'Save Password' functionality ...but how to add a attribute to a crispy-form (not to a input)?

Community
  • 1
  • 1
user2449761
  • 979
  • 10
  • 20

1 Answers1

1

If you are using a FormHelper, you can set attrs (docs).

For example to set autocomplete="off" as in the answer you linked to, you would do:

class ExampleForm(forms.Form):
    def __init__(self, *args, **kwargs):
        super(ExampleForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper(self)
        self.helper.attrs = {'autocomplete': 'off'}
Alasdair
  • 253,590
  • 43
  • 477
  • 449