Skip to content

Commit 7aeb37d

Browse files
committed
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
1 parent 871a99c commit 7aeb37d

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

django/contrib/admin/options.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,11 @@ def response_action(self, request, queryset):
698698
changelist; it returns an HttpResponse if the action was handled, and
699699
None otherwise.
700700
"""
701+
if 'index' not in request.POST:
702+
# If "Go" was not pushed then we can assume the POST was for
703+
# an inline edit save and we do not need to validate the form.
704+
return None
705+
701706
# There can be multiple action forms on the page (at the top
702707
# and bottom of the change list, for example). Get the action
703708
# whose button was pushed.

tests/regressiontests/admin_views/tests.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -940,6 +940,28 @@ def test_changelist_input_html(self):
940940
# 1 select per object = 3 selects
941941
self.failUnlessEqual(response.content.count("<select"), 4)
942942

943+
def test_post_messages(self):
944+
# Ticket 12707: Saving inline editable should not show admin
945+
# action warnings
946+
data = {
947+
"form-TOTAL_FORMS": "3",
948+
"form-INITIAL_FORMS": "3",
949+
"form-MAX_NUM_FORMS": "0",
950+
951+
"form-0-gender": "1",
952+
"form-0-id": "1",
953+
954+
"form-1-gender": "2",
955+
"form-1-id": "2",
956+
957+
"form-2-alive": "checked",
958+
"form-2-gender": "1",
959+
"form-2-id": "3",
960+
}
961+
response = self.client.post('/test_admin/admin/admin_views/person/',
962+
data, follow=True)
963+
self.assertEqual(len(response.context['messages']), 1)
964+
943965
def test_post_submission(self):
944966
data = {
945967
"form-TOTAL_FORMS": "3",

0 commit comments

Comments
 (0)