summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2011-02-20 13:44:37 +0000
committerRussell Keith-Magee <russell@keith-magee.com>2011-02-20 13:44:37 +0000
commit6ef2b4c2daa48e2644be6167f07b6f996914518b (patch)
treeba91fff9788ec83a32b41ed4b2267bd7d38b5c31
parent2377f109bca866821fe7556c3da19dbe0178e291 (diff)
[1.2.X] Tweaked the changes from changeset r15580 so as to avoid introducing a backwards incompatible context change to the change_list_results template. Refs #13126. Thanks to Sean Brant for the report.
Backport of r15593 from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@15594 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/contrib/admin/templates/admin/change_list_results.html4
-rw-r--r--django/contrib/admin/templatetags/admin_list.py13
2 files changed, 13 insertions, 4 deletions
diff --git a/django/contrib/admin/templates/admin/change_list_results.html b/django/contrib/admin/templates/admin/change_list_results.html
index faa5a2e6ba..bba42ef8e8 100644
--- a/django/contrib/admin/templates/admin/change_list_results.html
+++ b/django/contrib/admin/templates/admin/change_list_results.html
@@ -16,9 +16,9 @@
<tbody>
{% for result in results %}
{% if result.form.non_field_errors %}
- <tr><td colspan="{{ result.row|length }}">{{ result.form.non_field_errors }}</td></tr>
+ <tr><td colspan="{{ result|length }}">{{ result.form.non_field_errors }}</td></tr>
{% endif %}
-<tr class="{% cycle 'row1' 'row2' %}">{% for item in result.row %}{{ item }}{% endfor %}</tr>
+<tr class="{% cycle 'row1' 'row2' %}">{% for item in result %}{{ item }}{% endfor %}</tr>
{% endfor %}
</tbody>
</table>
diff --git a/django/contrib/admin/templatetags/admin_list.py b/django/contrib/admin/templatetags/admin_list.py
index dc2139821d..4e777ff1f0 100644
--- a/django/contrib/admin/templatetags/admin_list.py
+++ b/django/contrib/admin/templatetags/admin_list.py
@@ -196,13 +196,22 @@ def items_for_result(cl, result, form):
if form and not form[cl.model._meta.pk.name].is_hidden:
yield mark_safe(u'<td>%s</td>' % force_unicode(form[cl.model._meta.pk.name]))
+class ResultList(list):
+ # Wrapper class used to return items in a list_editable
+ # changelist, annotated with the form object for error
+ # reporting purposes. Needed to maintain backwards
+ # compatibility with existing admin templates.
+ def __init__(self, form, *items):
+ self.form = form
+ super(ResultList, self).__init__(*items)
+
def results(cl):
if cl.formset:
for res, form in zip(cl.result_list, cl.formset.forms):
- yield {'row': list(items_for_result(cl, res, form)), 'form': form}
+ yield ResultList(form, items_for_result(cl, res, form))
else:
for res in cl.result_list:
- yield {'row': list(items_for_result(cl, res, None)), 'form': None}
+ yield ResultList(None, items_for_result(cl, res, None))
def result_hidden_fields(cl):
if cl.formset: