Open realmhamdy opened 7 years ago
Better late then never, but I had the same problem today. I am using the SessionWizardView for user signup and when the users fills out the form everything goes as it should. When the user is created I automatically login the user. If a user if already logged in and tries to create a new account, Django recognizes that the user is already logged in and logs the existing user out when logging the new user in. When the existing user is logged out it flushes the whole session, including the wizard_signup_view data. After that the SessionWizardForm also tries to delete the wizard_signup_view data, but it does not exists and throws an error.
I fixed this problem by adding
if self.request.user.is_authenticated():
del self.request.session[SESSION_KEY]
self.request.user = AnonymousUser()
just before logging in the user after completing the signup form, so that Django does not logout the existing user and therefore not flushes the session.
This error is triggered when you flush the session in the wizard's done
method. Check if your method does any of these:
request.session.flush()
, ordjango.contrib.auth.logout()
(which always calls request.session.flush()
), ordjango.contrib.auth.login()
to log in another user when there is a user who is already logged in. In this scenario, django.contrib.auth.login()
will call django.contrib.auth.logout()
on the current user (thereby flushing the session) before logging in the new user.To temporarily work around this problem, avoid flushing the session in the wizard's done
method. If you're having this problem in a user sign up form, consider serving the sign up form to logged out users only by redirecting logged in users.
Hi there
So I'm using the
SessionWizardView
for the first 2 steps of a 3 step signup process. My issue is the same as the one mentioned on this stackoverflow question. Here's a copy of my stack trace:It seems to happen randomly and in bursts of successive errors from some user. I'm not doing anything special in my
render_done()
override appearing there on the trace. Just a variable assignment. Any help debugging this would be appreciated. Thanks!