I\'m trying to store the user\'s ID in the session using django.contrib.auth.login . But it is not working not as expected.
I\'m getting error login() takes exac
One possible fix:
from django.contrib import auth
def login(request):
# ....
auth.login(request, user)
# ...
Now your view name doesn't overwrite django's view name.
Your view function is also called login, and the call to login(request, user) ends up being interpreted as a attempt to call this function recursively:
def login(request):
...
login(request, user)
To avoid it rename your view function or refer to the login from django.contrib.auth in some different way. You could for example change the import to rename the login function:
from django.contrib.auth import login as auth_login
...
auth_login(request, user)
Another way:
from django.contrib.auth import login as auth_login
then call auth_login(request, user) instead of login(request, user).