升级到django 1.7之后,我会在管理页面中编辑模型时获得以下追溯(IE点击单个模型的条目以访问其详细信息)
应用程序和管理员似乎在迁移后工作,直到我去执行此操作。显然(?)我没有管理方面的测试,所以我只是在尝试时发现了这个。
知道需要做些什么来纠正它?我是否有1.6中不受支持的剩余旧模板,或者我是否无法更新某些内容以使用新模板正常工作?
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
完全追溯(希望我能发布这个“崩溃”!)
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'
答案 0 :(得分:1)
你可能有一个二次追溯。尝试直接在命令行上获取主要的,而不是在Web浏览器中。尝试使用以下内容重现该错误:
python manage.py runserver --traceback --nothreading --noreload
只有第一个选项非常重要。其他选项只会简化调试。
您的错误发生在班级ErrorList
中。 UserList类仅用于Django 1.7,而不是任何旧的Django,因为它在以前的任何Django中都不存在。
答案 1 :(得分:1)
事实证明,这是由于django-nested-inlines的过时版本所致。
调试的线索来自询问“什么是这个AdminErrorList?”,这导致“什么是admin.py?”,这导致“哇,这个嵌套线是什么东西,它是1.7兼容的”
最近有一个关于django嵌套内联的提交引用了与AdminErrorList相关的更新,这个更改解决了我的问题。