Ticket #10460: views.py.diff

File views.py.diff, 1.2 KB (added by Felipe 'chronos' Prenholato, 16 years ago)

Patch to make logout redirects like login view.

  • django/contrib/auth/views.py

     
    4242    }, context_instance=RequestContext(request))
    4343login = never_cache(login)
    4444
    45 def logout(request, next_page=None, template_name='registration/logged_out.html'):
     45def logout(request, next_page=None, template_name='registration/logged_out.html', redirect_to=REDIRECT_FIELD_NAME):
    4646    "Logs out the user and displays 'You are logged out' message."
    4747    from django.contrib.auth import logout
    4848    logout(request)
    4949    if next_page is None:
    50         return render_to_response(template_name, {'title': _('Logged out')}, context_instance=RequestContext(request))
     50        redirect_to = request.REQUEST.get(redirect_field_name, '')
     51        if redirect_to:
     52            return HttpResponseRedirect(redirect_to)
     53        else:
     54            return render_to_response(template_name, {'title': _('Logged out')}, context_instance=RequestContext(request))
    5155    else:
    5256        # Redirect to this page until the session has been cleared.
    5357        return HttpResponseRedirect(next_page or request.path)
Back to Top