Skip to content
Browse files

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.

git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent 1073a83 commit 674062c355b1acdc49c2b0cf2ba0d23e0eb8371c @freakboy3742 freakboy3742 committed
4 django/contrib/admin/templates/admin/change_list_results.html
@@ -17,9 +17,9 @@
{% 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 %}
13 django/contrib/admin/templatetags/
@@ -195,13 +195,22 @@ def items_for_result(cl, result, form):
if form and not form[].is_hidden:
yield mark_safe(u'<td>%s</td>' % force_unicode(form[]))
+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))
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:

0 comments on commit 674062c

Please sign in to comment.
Something went wrong with that request. Please try again.