Commits

Luke Plant committed 02144a0

[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

  • Participants
  • Parent commits 9dae23b
  • Branches releases/1.2.X

Comments (0)

Files changed (2)

django/contrib/admin/options.py

             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)

tests/regressiontests/admin_views/tests.py

         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/')