summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Kocherhans <joseph@jkocherhans.com>2010-02-23 14:48:15 +0000
committerJoseph Kocherhans <joseph@jkocherhans.com>2010-02-23 14:48:15 +0000
commit7aeb37d610700fe25b07d5e76b943cc3d51ab1a5 (patch)
tree059a646c37688277a9daac5479e3b31cabd7bbdf
parent871a99c948bcfe7e59bf93df4bcd00cffcbf94f2 (diff)
Fixed #12707. Admin action messages are no longer displayed when submitting list_editable content. Thanks, copelco.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12525 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/contrib/admin/options.py5
-rw-r--r--tests/regressiontests/admin_views/tests.py22
2 files changed, 27 insertions, 0 deletions
diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
index 00174bca73..b110596d8a 100644
--- a/django/contrib/admin/options.py
+++ b/django/contrib/admin/options.py
@@ -698,6 +698,11 @@ class ModelAdmin(BaseModelAdmin):
changelist; it returns an HttpResponse if the action was handled, and
None otherwise.
"""
+ if 'index' not in request.POST:
+ # If "Go" was not pushed then we can assume the POST was for
+ # an inline edit save and we do not need to validate the form.
+ return None
+
# There can be multiple action forms on the page (at the top
# and bottom of the change list, for example). Get the action
# whose button was pushed.
diff --git a/tests/regressiontests/admin_views/tests.py b/tests/regressiontests/admin_views/tests.py
index 0f6f79d85c..199b41afcb 100644
--- a/tests/regressiontests/admin_views/tests.py
+++ b/tests/regressiontests/admin_views/tests.py
@@ -940,6 +940,28 @@ class AdminViewListEditable(TestCase):
# 1 select per object = 3 selects
self.failUnlessEqual(response.content.count("<select"), 4)
+ def test_post_messages(self):
+ # Ticket 12707: Saving inline editable should not show admin
+ # action warnings
+ data = {
+ "form-TOTAL_FORMS": "3",
+ "form-INITIAL_FORMS": "3",
+ "form-MAX_NUM_FORMS": "0",
+
+ "form-0-gender": "1",
+ "form-0-id": "1",
+
+ "form-1-gender": "2",
+ "form-1-id": "2",
+
+ "form-2-alive": "checked",
+ "form-2-gender": "1",
+ "form-2-id": "3",
+ }
+ response = self.client.post('/test_admin/admin/admin_views/person/',
+ data, follow=True)
+ self.assertEqual(len(response.context['messages']), 1)
+
def test_post_submission(self):
data = {
"form-TOTAL_FORMS": "3",