1

我将一个项目从 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 : &rsaquo; <a href=" {% url 'admin:app_list' app_label=cl.opts.app_label %} ">{{ app_label|capfirst|escape }}</a>


   45 : &rsaquo; {{ 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.
4

1 回答 1

0

我的错误最终相当愚蠢。我的一个自定义上下文处理器重新定义了“cl”上下文变量,因此使以下标记失败:

{% url 'admin:app_list' app_label=cl.opts.app_label %}

我只需要对我自己的上下文处理器和模板进行一些更改(并使用更好的上下文处理器变量名称)。

笔记:我不知道为什么这之前没有让我感到困扰。理论上,即使在 1.1 中,它也应该是一个问题。

于 2012-06-07T16:03:04.557 回答