Logout method returning "maximum recursion depth exceeded" - Help!

2,660 views
Skip to first unread message

MerMer

unread,
Oct 26, 2006, 6:24:57 AM10/26/06
to Django users
I am trying to get the Logout Method to work, but I keep
getting"Exception Value: maximum recursion depth exceeded!".

The view is very straightforward, so I can't understand where I'm going
wrong.

from django.contrib.auth import logout, authenticate, login

def logout(request):
logout(request) # debug shows it fails on this line
return render_to_response('promotions.html')

Don Arbow

unread,
Oct 27, 2006, 11:37:39 AM10/27/06
to django...@googlegroups.com
Probably because python is calling the wrong logout method (yours and not django's). I would instead qualify the logout method you are calling like this:

from django.contrib import auth

def logout(request):
auth.logout(request)
...

or you could rename your logout method to something else, like log_me_out(), which should prevent the recursion.

Don

Karen Tracey

unread,
Oct 27, 2006, 11:42:04 AM10/27/06
to django...@googlegroups.com
Yeah, you've got infinite recursion in the first line of your logout
function: it calls itself. I'm not sure why you are even defining
your own logout view? I have my urls.py map my logout url to
django.contrib.auth.views.logout, and supply a context that includes
template_name to display my own logout template. Specifically, my
urls.py includes this line:

(r'accounts/logout/$', 'django.contrib.auth.views.logout',
{'template_name': 'cdbauth/logged_out.tmpl'}),

Given you don't do anything extra in your logout view, I think you
could do the same, just replace the first parameter with your own
chosen logout url and the last one with your template name?

Karen

p.s. Is google groups acting up? I just got a bunch of old mails
(like this one), and my first attempt to post this via the groups
page gave me an "oops, we're sorry, can't do, please try again later"
kind of message? (Gah, as did my 2nd....I'll try again with real mail...)

Merric Mercer

unread,
Oct 27, 2006, 12:40:19 PM10/27/06
to django...@googlegroups.com
Thanks for all your points. I'm having real problems with Google
groups. I figured out what was wrong - but was not able to post in.
Now, these posts are obviously coming in - 24 late.

MerMer

Reply all
Reply to author
Forward
0 new messages