Password change view throws 500 if unauthenticated
Internal Server Error: /accounts/password/change/
Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "/usr/local/lib/python3.9/dist-packages/django/core/handlers/base.py", line 181, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python3.9/dist-packages/django/views/generic/base.py", line 70, in view
return self.dispatch(request, *args, **kwargs)
File "/usr/local/lib/python3.9/dist-packages/django/contrib/auth/mixins.py", line 104, in dispatch
return super().dispatch(request, *args, **kwargs)
File "/usr/local/lib/python3.9/dist-packages/django/utils/decorators.py", line 43, in _wrapper
return bound_method(*args, **kwargs)
File "/usr/local/lib/python3.9/dist-packages/django/views/decorators/debug.py", line 89, in sensitive_post_parameters_wrapper
return view(request, *args, **kwargs)
File "/usr/local/lib/python3.9/dist-packages/allauth/account/views.py", line 592, in dispatch
return super(PasswordChangeView, self).dispatch(request, *args, **kwargs)
File "/usr/local/lib/python3.9/dist-packages/django/views/generic/base.py", line 98, in dispatch
return handler(request, *args, **kwargs)
File "/usr/local/lib/python3.9/dist-packages/allauth/account/views.py", line 90, in get
response = super(AjaxCapableProcessFormViewMixin, self).get(
File "/usr/local/lib/python3.9/dist-packages/django/views/generic/edit.py", line 133, in get
return self.render_to_response(self.get_context_data())
File "/usr/local/lib/python3.9/dist-packages/allauth/account/views.py", line 595, in render_to_response
if not self.request.user.has_usable_password():
File "/usr/local/lib/python3.9/dist-packages/django/utils/functional.py", line 247, in inner
return func(self._wrapped, *args)
File "/usr/local/lib/python3.9/dist-packages/django/utils/functional.py", line 247, in inner
return func(self._wrapped, *args)
File "/usr/local/lib/python3.9/dist-packages/django/utils/functional.py", line 247, in inner
return func(self._wrapped, *args)
AttributeError: 'AnonymousUser' object has no attribute 'has_usable_password'
The View should redirect to the login page if user is unauthenticated.