Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #9514 -- Made admin change_form template correctly recognize/re…

…port when a form has only a single error.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@9371 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit c367e2869eaa28598aab7aa7ea2e76b596fe09b2 1 parent b81bc22
Karen Tracey kmtracey authored
2  django/contrib/admin/templates/admin/change_form.html
View
@@ -35,7 +35,7 @@
{% if save_on_top %}{% submit_row %}{% endif %}
{% if errors %}
<p class="errornote">
- {% blocktrans count errors.items|length as counter %}Please correct the error below.{% plural %}Please correct the errors below.{% endblocktrans %}
+ {% blocktrans count errors|length as counter %}Please correct the error below.{% plural %}Please correct the errors below.{% endblocktrans %}
</p>
<ul class="errorlist">{% for error in adminform.form.non_field_errors %}<li>{{ error }}</li>{% endfor %}</ul>
{% endif %}
12 tests/regressiontests/admin_views/tests.py
View
@@ -387,6 +387,18 @@ def testChangeView(self):
post = self.client.post('/test_admin/admin/admin_views/article/1/', change_dict)
self.assertRedirects(post, '/test_admin/admin/admin_views/article/')
self.failUnlessEqual(Article.objects.get(pk=1).content, '<p>edited article</p>')
+
+ # one error in form should produce singular error message, multiple errors plural
+ change_dict['title'] = ''
+ post = self.client.post('/test_admin/admin/admin_views/article/1/', change_dict)
+ self.failUnlessEqual(request.status_code, 200)
+ self.failUnless('Please correct the error below.' in post.content,
+ 'Singular error message not found in response to post with one error.')
+ change_dict['content'] = ''
+ post = self.client.post('/test_admin/admin/admin_views/article/1/', change_dict)
+ self.failUnlessEqual(request.status_code, 200)
+ self.failUnless('Please correct the errors below.' in post.content,
+ 'Plural error message not found in response to post with multiple errors.')
self.client.get('/test_admin/admin/logout/')
def testCustomModelAdminTemplates(self):
Please sign in to comment.
Something went wrong with that request. Please try again.