diff --git a/django/contrib/auth/views.py b/django/contrib/auth/views.py index e24af5d9b0..85893aff8b 100644 --- a/django/contrib/auth/views.py +++ b/django/contrib/auth/views.py @@ -83,6 +83,11 @@ class LoginView(SuccessURLAllowedHostsMixin, FormView): def get_form_class(self): return self.authentication_form or self.form_class + def get_form_kwargs(self): + kwargs = super().get_form_kwargs() + kwargs['request'] = self.request + return kwargs + def form_valid(self, form): """Security check complete. Log the user in.""" auth_login(self.request, form.get_user()) @@ -100,11 +105,6 @@ class LoginView(SuccessURLAllowedHostsMixin, FormView): context.update(self.extra_context) return context - def get_form_kwargs(self): - kwargs = super().get_form_kwargs() - kwargs['request'] = self.request - return kwargs - def login(request, *args, **kwargs): warnings.warn(