1👍
✅
You shouldn’t call your backend methods directly. Instead, use the functions defined in django.contrib.auth
:
from django.contrib.auth import authenticate
class MyAuthForm(AuthenticationForm):
...
def clean(self):
...
self.user_cache = authenticate(username=self.cleaned_data['username'],
password=self.cleaned_data['password'], v_code=self.cleaned_data['v_code'])
...
This will try each configured backend until authentication is successful.
👤knbk
Source:stackexchange.com