我将项目从1.1迁移到1.2,然后迁移到1.3,所有这一切都完美无缺。但是,当我将版本移动到1.4时,我不断获得
NoReverseMatch at /admin/<app_name>/<model_name>/
Reverse for 'app_list' with arguments '()' and keyword arguments '{'app_label': ''}' not found.
所有其他管理功能似乎都运行正常,但每次我尝试查看列表时,都会收到NoReverseMatch错误。
管理员的我的网址是:
(r'^admin/', include(admin.site.urls)),
这是我的追溯:
Template error:
In template /home/ibustama/yalea/env-yalea/lib/python2.6/site-packages/django/contrib/admin/templates/admin/change_list.html, error at line 44
Reverse for 'app_list' with arguments '()' and keyword arguments '{'app_label': ''}' not found.
34 : </script>
35 : {% endif %}{% endif %}
36 : {% endblock %}
37 :
38 : {% block bodyclass %}change-list{% endblock %}
39 :
40 : {% if not is_popup %}
41 : {% block breadcrumbs %}
42 : <div class="breadcrumbs">
43 : <a href="{% url 'admin:index' %}">{% trans 'Home' %}</a>
44 : › <a href=" {% url 'admin:app_list' app_label=cl.opts.app_label %} ">{{ app_label|capfirst|escape }}</a>
45 : › {{ cl.opts.verbose_name_plural|capfirst }}
46 : </div>
47 : {% endblock %}
48 : {% endif %}
49 :
50 : {% block coltype %}flex{% endblock %}
51 :
52 : {% block content %}
53 : <div id="content-main">
54 : {% block object-tools %}
Traceback:
File "/home/ibustama/yalea/env-yalea/lib/python2.6/site-packages/django/core/handlers/base.py" in get_response
136. response = response.render()
File "/home/ibustama/yalea/env-yalea/lib/python2.6/site-packages/django/template/response.py" in render
104. self._set_content(self.rendered_content)
File "/home/ibustama/yalea/env-yalea/lib/python2.6/site-packages/django/template/response.py" in rendered_content
81. content = template.render(context)
File "/home/ibustama/yalea/env-yalea/lib/python2.6/site-packages/django/template/base.py" in render
140. return self._render(context)
File "/home/ibustama/yalea/env-yalea/lib/python2.6/site-packages/django/template/base.py" in _render
134. return self.nodelist.render(context)
File "/home/ibustama/yalea/env-yalea/lib/python2.6/site-packages/django/template/base.py" in render
823. bit = self.render_node(node, context)
File "/home/ibustama/yalea/env-yalea/lib/python2.6/site-packages/django/template/debug.py" in render_node
74. return node.render(context)
File "/home/ibustama/yalea/env-yalea/lib/python2.6/site-packages/django/template/loader_tags.py" in render
123. return compiled_parent._render(context)
File "/home/ibustama/yalea/env-yalea/lib/python2.6/site-packages/django/template/base.py" in _render
134. return self.nodelist.render(context)
File "/home/ibustama/yalea/env-yalea/lib/python2.6/site-packages/django/template/base.py" in render
823. bit = self.render_node(node, context)
File "/home/ibustama/yalea/env-yalea/lib/python2.6/site-packages/django/template/debug.py" in render_node
74. return node.render(context)
File "/home/ibustama/yalea/env-yalea/lib/python2.6/site-packages/django/template/loader_tags.py" in render
123. return compiled_parent._render(context)
File "/home/ibustama/yalea/env-yalea/lib/python2.6/site-packages/django/template/base.py" in _render
134. return self.nodelist.render(context)
File "/home/ibustama/yalea/env-yalea/lib/python2.6/site-packages/django/template/base.py" in render
823. bit = self.render_node(node, context)
File "/home/ibustama/yalea/env-yalea/lib/python2.6/site-packages/django/template/debug.py" in render_node
74. return node.render(context)
File "/home/ibustama/yalea/env-yalea/lib/python2.6/site-packages/django/template/defaulttags.py" in render
281. return nodelist.render(context)
File "/home/ibustama/yalea/env-yalea/lib/python2.6/site-packages/django/template/base.py" in render
823. bit = self.render_node(node, context)
File "/home/ibustama/yalea/env-yalea/lib/python2.6/site-packages/django/template/debug.py" in render_node
74. return node.render(context)
File "/home/ibustama/yalea/env-yalea/lib/python2.6/site-packages/django/template/loader_tags.py" in render
62. result = block.nodelist.render(context)
File "/home/ibustama/yalea/env-yalea/lib/python2.6/site-packages/django/template/base.py" in render
823. bit = self.render_node(node, context)
File "/home/ibustama/yalea/env-yalea/lib/python2.6/site-packages/django/template/debug.py" in render_node
74. return node.render(context)
File "/home/ibustama/yalea/env-yalea/lib/python2.6/site-packages/django/template/defaulttags.py" in render
424. raise e
Exception Type: NoReverseMatch at /admin/auth/user/
Exception Value: Reverse for 'app_list' with arguments '()' and keyword arguments '{'app_label': ''}' not found.
答案 0 :(得分:0)
我的错误最终是相当愚蠢的。我的一个自定义上下文处理器重新定义了“cl”上下文var,因此使以下标记失败:
{% url 'admin:app_list' app_label=cl.opts.app_label %}
我只需要对自己的上下文处理器和模板进行一些更改(并使用更好的上下文处理器var名称)。
注意:我不知道为什么以前没有打扰过我。理论上,即使在1.1中也应该是一个问题。