From 03afc74c1edaf9cbaa34579c59acf4868d4e5b37 Mon Sep 17 00:00:00 2001 From: Trent Palmer Date: Sun, 28 Mar 2021 14:08:01 -0700 Subject: [PATCH] add totp form autofocus attr --- accounts/forms.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/accounts/forms.py b/accounts/forms.py index 1d57de1..c72469d 100644 --- a/accounts/forms.py +++ b/accounts/forms.py @@ -8,6 +8,10 @@ class EnableTotpForm(forms.ModelForm): totp_code = forms.CharField(max_length=6) + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self.fields['totp_code'].widget.attrs.update({'autofocus': 'autofocus'}) + class Meta: model = Account fields = ("totp_code", )