When I try to logout from my django project, I get the following error:
"maximum recursion depth exceeded while calling a Python object"
Here is the url for the logout button:
url(r'^logout', 'users.views.logout', name='logout'),
And here is the view:
from django.shortcuts import render
from deck1.models import Card
from django.template import RequestContext
from django.shortcuts import render_to_response
from django.http import HttpResponseRedirect, HttpResponse
from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth.forms import AuthenticationForm
from django.contrib.auth import login, authenticate, logout
from django.contrib.auth.decorators import login_required
from users.forms import RegisterForm
@login_required
def logout(request):
logout(request)
return HttpResponseRedirect('/deck')
Your view logout
is overriding the namespace of built-in logout
function. Define an alias for django.contrib.auth.login
function using as
keyword.
from django.contrib.auth import logout as django_logout
@login_required
def logout(request):
django_logout(request)
return HttpResponseRedirect('/deck')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With