diff options
| author | Luke Plant <L.Plant.98@cantab.net> | 2010-09-07 20:59:28 +0000 |
|---|---|---|
| committer | Luke Plant <L.Plant.98@cantab.net> | 2010-09-07 20:59:28 +0000 |
| commit | a04398eb1b958830698fe42bd9f5244662e7d8b3 (patch) | |
| tree | 38c4754c999ef0da9b32157d7978ff5d9abc002c | |
| parent | 1b910d7fbcc664ae22bef010af05746027b82138 (diff) | |
[1.2.X] Fixed #13081 - Admin actions lose get-parameters in changelist view
Thanks to joh for report and to SmileyChris for patch.
Backport of [13696] from trunk
git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@13697 bcc190cf-cafb-0310-a4f2-bffc1f526a37
| -rw-r--r-- | django/contrib/admin/options.py | 2 | ||||
| -rw-r--r-- | tests/regressiontests/admin_views/tests.py | 15 |
2 files changed, 16 insertions, 1 deletions
diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py index 1f8ff6dbd1..3a824c6e0a 100644 --- a/django/contrib/admin/options.py +++ b/django/contrib/admin/options.py @@ -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) diff --git a/tests/regressiontests/admin_views/tests.py b/tests/regressiontests/admin_views/tests.py index f5a54f3f6c..f76765236e 100644 --- a/tests/regressiontests/admin_views/tests.py +++ b/tests/regressiontests/admin_views/tests.py @@ -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/') |
