Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[1.1.X] Fixed #12716 - Typo in the admin change list template. Thanks…

…, kbrownlees.

Backport of r12398 and r12448.

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.1.X@12453 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 77192eb661ffc1768d75cb3ed4f253240da8e6c0 1 parent df1ad56
Jannis Leidel jezdez authored
2  django/contrib/admin/templates/admin/change_list.html
View
@@ -54,7 +54,7 @@
<p class="errornote">
{% blocktrans count cl.formset.errors|length as counter %}Please correct the error below.{% plural %}Please correct the errors below.{% endblocktrans %}
</p>
- <ul class="errorlist">{% for error in cl.formset.non_field_errors %}<li>{{ error }}</li>{% endfor %}</ul>
+ <ul class="errorlist">{% for error in cl.formset.non_form_errors %}<li>{{ error }}</li>{% endfor %}</ul>
{% endif %}
<div class="module{% if cl.has_filters %} filtered{% endif %}" id="changelist">
{% block search %}{% search_form cl %}{% endblock %}
14 tests/regressiontests/admin_views/models.py
View
@@ -5,6 +5,8 @@
from django.db import models
from django.contrib import admin
from django.core.mail import EmailMessage
+from django import forms
+from django.forms.models import BaseModelFormSet
class Section(models.Model):
"""
@@ -168,6 +170,14 @@ def __unicode__(self):
class Meta:
ordering = ["id"]
+class BasePersonModelFormSet(BaseModelFormSet):
+ def clean(self):
+ for person_dict in self.cleaned_data:
+ person = person_dict.get('id')
+ alive = person_dict.get('alive')
+ if person and alive and person.name == "Grace Hopper":
+ raise forms.ValidationError, "Grace is not a Zombie"
+
class PersonAdmin(admin.ModelAdmin):
list_display = ('name', 'gender', 'alive')
list_editable = ('gender', 'alive')
@@ -176,6 +186,10 @@ class PersonAdmin(admin.ModelAdmin):
ordering = ["id"]
save_as = True
+ def get_changelist_formset(self, request, **kwargs):
+ return super(PersonAdmin, self).get_changelist_formset(request,
+ formset=BasePersonModelFormSet, **kwargs)
+
class Persona(models.Model):
"""
A simple persona associated with accounts, to test inlining of related
14 tests/regressiontests/admin_views/tests.py
View
@@ -921,7 +921,6 @@ def test_post_submission(self):
"form-2-id": "3",
}
self.client.post('/test_admin/admin/admin_views/person/', data)
-
self.failUnlessEqual(Person.objects.get(name="John Mauchly").alive, False)
self.failUnlessEqual(Person.objects.get(name="Grace Hopper").gender, 2)
@@ -954,6 +953,19 @@ def test_post_submission(self):
self.failUnlessEqual(Person.objects.get(name="John Mauchly").alive, False)
+ def test_non_form_errors(self):
+ # test if non-form errors are handled; ticket #12716
+ data = {
+ "form-TOTAL_FORMS": "1",
+ "form-INITIAL_FORMS": "1",
+
+ "form-0-id": "2",
+ "form-0-alive": "1",
+ "form-0-gender": "2",
+ }
+ response = self.client.post('/test_admin/admin/admin_views/person/', data)
+ self.assertContains(response, "Grace is not a Zombie")
+
def test_list_editable_ordering(self):
collector = Collector.objects.create(id=1, name="Frederick Clegg")
Please sign in to comment.
Something went wrong with that request. Please try again.