[Answer]-Django user login after creation isn't working

1πŸ‘

βœ…

It turns out it’s the same issue as Django automatic login after user registration (1.4)

Following was my import statement:

from django.contrib.auth import forms as auth_forms, views as auth_views, login, authenticate

Changed it to

from django.contrib.auth import forms as auth_forms, views as auth_views
from django.contrib.auth import login as auth_login, authenticate as auth_authenticate

and updated all the login and authenticate call to auth_login and auth_authenticate and seems to work now.

Thank you all for your help !

πŸ‘€Andrew Hong

0πŸ‘

It’s just a guess, but maybe super().form_valid() is saving the UserCreationForm a second time, which will call set_password() again, therefore setting a new salted password, invalidating your first login πŸ™‚

https://docs.djangoproject.com/en/1.7/_modules/django/contrib/auth/forms/#UserCreationForm

πŸ‘€ACimander

Leave a comment