239👍
✅
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)
👤sth
16👍
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.
👤ars
- [Django]-Programmatically saving image to Django ImageField
- [Django]-How do I package a python application to make it pip-installable?
- [Django]-How to resize the new uploaded images using PIL before saving?
8👍
Another way:
from django.contrib.auth import login as auth_login
then call auth_login(request, user)
instead of login(request, user)
.
- [Django]-Django: How to format a DateField's date representation?
- [Django]-Images from ImageField in Django don't load in template
- [Django]-Default value for user ForeignKey with Django admin
Source:stackexchange.com