Search code examples
djangodjango-1.7

Error on accessing model details in admin after upgrade to django 1.7


After upgrading to django 1.7, I get the following traceback, upon going to edit a model in the admin pages (IE clicking the entry of an individual model to access its details)

The app and admin appeared to be working after migration until I went to do this. Obviously (?) I don't have tests for the admin side of things, so I only discovered this when I tried it.

Any idea what need to do to correct it? Do I have some leftover old template from 1.6 that isn't supported, or have I failed to update something to work properly with a new one?

Exception Type: AttributeError at /admin/cmh_server/module/7/
In template /Users/mgregory/Documents/virtualenvs/cm_central/lib/python2.7/site-packages/django/contrib/admin/templates/admin/change_form.html, 
error at line 45
'AdminErrorList' object has no attribute 'data'
35      {% if has_absolute_url %}<li><a href="{{ absolute_url }}" class="viewsitelink">{% trans "View on site" %}</a></li>{% endif%}
36      {% endblock %}
37    </ul>
38  {% endif %}{% endif %}
39  {% endblock %}
40  <form {% if has_file_field %}enctype="multipart/form-data" {% endif %}action="{{ form_url }}" method="post" id="{{ opts.model_name }}_form" novalidate>{% csrf_token %}{% block form_top %}{% endblock %}
41  <div>
42  {% if is_popup %}<input type="hidden" name="{{ is_popup_var }}" value="1" />{% endif %}
43  {% if to_field %}<input type="hidden" name="{{ to_field_var }}" value="{{ to_field }}" />{% endif %}
44  {% if save_on_top %}{% block submit_buttons_top %}{% submit_row %}{% endblock %}{% endif %}
45  {% if errors %}
46      <p class="errornote">
47      {% if errors|length == 1 %}{% trans "Please correct the error below." %}{% else %}{% trans "Please correct the errors below." %}{% endif %}
48      </p>
49      {{ adminform.form.non_field_errors }}
50  {% endif %}
51  

Full traceback (wish I could post this "collapsed"!)

File "/Users/mgregory/Documents/virtualenvs/cm_central/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  137.                 response = response.render()
File "/Users/mgregory/Documents/virtualenvs/cm_central/lib/python2.7/site-packages/django/template/response.py" in render
  103.             self.content = self.rendered_content
File "/Users/mgregory/Documents/virtualenvs/cm_central/lib/python2.7/site-packages/django/template/response.py" in rendered_content
  80.         content = template.render(context)
File "/Users/mgregory/Documents/virtualenvs/cm_central/lib/python2.7/site-packages/django/template/base.py" in render
  148.             return self._render(context)
File "/Users/mgregory/Documents/virtualenvs/cm_central/lib/python2.7/site-packages/django/template/base.py" in _render
  142.         return self.nodelist.render(context)
File "/Users/mgregory/Documents/virtualenvs/cm_central/lib/python2.7/site-packages/django/template/base.py" in render
  844.                 bit = self.render_node(node, context)
File "/Users/mgregory/Documents/virtualenvs/cm_central/lib/python2.7/site-packages/django/template/debug.py" in render_node
  80.             return node.render(context)
File "/Users/mgregory/Documents/virtualenvs/cm_central/lib/python2.7/site-packages/django/template/loader_tags.py" in render
  126.         return compiled_parent._render(context)
File "/Users/mgregory/Documents/virtualenvs/cm_central/lib/python2.7/site-packages/django/template/base.py" in _render
  142.         return self.nodelist.render(context)
File "/Users/mgregory/Documents/virtualenvs/cm_central/lib/python2.7/site-packages/django/template/base.py" in render
  844.                 bit = self.render_node(node, context)
File "/Users/mgregory/Documents/virtualenvs/cm_central/lib/python2.7/site-packages/django/template/debug.py" in render_node
  80.             return node.render(context)
File "/Users/mgregory/Documents/virtualenvs/cm_central/lib/python2.7/site-packages/django/template/loader_tags.py" in render
  126.         return compiled_parent._render(context)
File "/Users/mgregory/Documents/virtualenvs/cm_central/lib/python2.7/site-packages/django/template/base.py" in _render
  142.         return self.nodelist.render(context)
File "/Users/mgregory/Documents/virtualenvs/cm_central/lib/python2.7/site-packages/django/template/base.py" in render
  844.                 bit = self.render_node(node, context)
File "/Users/mgregory/Documents/virtualenvs/cm_central/lib/python2.7/site-packages/django/template/debug.py" in render_node
  80.             return node.render(context)
File "/Users/mgregory/Documents/virtualenvs/cm_central/lib/python2.7/site-packages/django/template/loader_tags.py" in render
  65.                 result = block.nodelist.render(context)
File "/Users/mgregory/Documents/virtualenvs/cm_central/lib/python2.7/site-packages/django/template/base.py" in render
  844.                 bit = self.render_node(node, context)
File "/Users/mgregory/Documents/virtualenvs/cm_central/lib/python2.7/site-packages/django/template/debug.py" in render_node
  80.             return node.render(context)
File "/Users/mgregory/Documents/virtualenvs/cm_central/lib/python2.7/site-packages/django/template/defaulttags.py" in render
  311.             if match:
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/UserList.py" in __len__
  30.     def __len__(self): return len(self.data)
Exception Type: AttributeError at /admin/cmh_server/module/7/
Exception Value: 'AdminErrorList' object has no attribute 'data'

Solution

  • It turns out that this was due to an out-of-date version of django-nested-inlines.

    The clue for debugging came from asking "what is this AdminErrorList?", which lead to "what is in admin.py?", which lead to "whoa, what is this nested-lines thing, is it 1.7 compliant".

    There was a recent commit on django-nested-inlines that referred to updates relating to AdminErrorList, and this change fixed my problem.