Fixed #13081 - Admin actions lose get-parameters in changelist view

Thanks to joh for report and to SmileyChris for patch.



git-svn-id: http://code.djangoproject.com/svn/django/trunk@13696 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Luke Plant 2010-09-07 20:55:53 +00:00
parent e5d30c7001
commit ef4b29a001
2 changed files with 16 additions and 1 deletions

View File

@ -754,7 +754,7 @@ class ModelAdmin(BaseModelAdmin):
if isinstance(response, HttpResponse):
return response
else:
return HttpResponseRedirect(".")
return HttpResponseRedirect(request.get_full_path())
else:
msg = _("No action selected.")
self.message_user(request, msg)

View File

@ -1477,6 +1477,21 @@ class AdminActionsTest(TestCase):
response = self.client.post('/test_admin/admin/admin_views/externalsubscriber/', action_data)
self.failUnlessEqual(response.status_code, 302)
def test_default_redirect(self):
"""
Test that actions which don't return an HttpResponse are redirected to
the same page, retaining the querystring (which may contain changelist
information).
"""
action_data = {
ACTION_CHECKBOX_NAME: [1],
'action' : 'external_mail',
'index': 0,
}
url = '/test_admin/admin/admin_views/externalsubscriber/?ot=asc&o=1'
response = self.client.post(url, action_data)
self.assertRedirects(response, url)
def test_model_without_action(self):
"Tests a ModelAdmin without any action"
response = self.client.get('/test_admin/admin/admin_views/oldsubscriber/')