diff --git a/django/contrib/auth/tests/views.py b/django/contrib/auth/tests/views.py
index 530956a..836d912 100644
a
|
b
|
class LogoutTest(AuthViewsTestCase):
|
333 | 333 | response = self.client.get('/logout/') |
334 | 334 | self.assertTrue('site' in response.context) |
335 | 335 | |
| 336 | def test_11223(self): |
| 337 | # Bug 11223 |
| 338 | self.login() |
| 339 | response = self.client.get('/logout/next_page/') |
| 340 | self.assertEqual(response.status_code, 302) |
| 341 | self.assert_(response['Location'].endswith('/somewhere/')) |
| 342 | |
| 343 | response = self.client.get('/logout/?next=/login/') |
| 344 | self.assertEqual(response.status_code, 302) |
| 345 | self.assert_(response['Location'].endswith('/login/')) |
| 346 | |
| 347 | self.confirm_logged_out() |
| 348 | |
336 | 349 | def test_logout_with_next_page_specified(self): |
337 | 350 | "Logout with next_page option given redirects to specified resource" |
338 | 351 | self.login() |
diff --git a/django/contrib/auth/views.py b/django/contrib/auth/views.py
index c34a4a3..19edb70 100644
a
|
b
|
def logout(request, next_page=None,
|
74 | 74 | "Logs out the user and displays 'You are logged out' message." |
75 | 75 | from django.contrib.auth import logout |
76 | 76 | logout(request) |
| 77 | redirect_to = request.REQUEST.get(redirect_field_name, '') |
| 78 | if redirect_to: |
| 79 | return HttpResponseRedirect(redirect_to) |
| 80 | |
77 | 81 | if next_page is None: |
78 | | redirect_to = request.REQUEST.get(redirect_field_name, '') |
79 | | if redirect_to: |
80 | | return HttpResponseRedirect(redirect_to) |
81 | | else: |
82 | | current_site = get_current_site(request) |
83 | | context = { |
84 | | 'site': current_site, |
85 | | 'site_name': current_site.name, |
86 | | 'title': _('Logged out') |
87 | | } |
88 | | context.update(extra_context or {}) |
89 | | return render_to_response(template_name, context, |
90 | | context_instance=RequestContext(request, current_app=current_app)) |
| 82 | current_site = get_current_site(request) |
| 83 | context = { |
| 84 | 'site': current_site, |
| 85 | 'site_name': current_site.name, |
| 86 | 'title': _('Logged out') |
| 87 | } |
| 88 | context.update(extra_context or {}) |
| 89 | return render_to_response(template_name, context, |
| 90 | context_instance=RequestContext(request, current_app=current_app)) |
91 | 91 | else: |
92 | 92 | # Redirect to this page until the session has been cleared. |
93 | 93 | return HttpResponseRedirect(next_page or request.path) |