另一个django NoReverseMatch [英] Another django NoReverseMatch

查看:179
本文介绍了另一个django NoReverseMatch的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在project.urls中:

In project.urls:

url(r'^category/', include('category.urls')),

在项目/ category / category.urls(以'project.category.views'为前缀的模式) :

In project/category/category.urls (patterns prefixed with 'project.category.views'):

url(r'^list/', 'category_list', name='category_list_name'),

在项目/ templates / base.html中:

In project/templates/base.html:

{% url 'category_list_name' %}

给我:

Caught NoReverseMatch while rendering: Reverse for ''category_list_name'' with arguments '()' and keyword arguments '{}' not found.

在shell中,我收到相同的错误:

In the shell, I get the same error for this:

>>> reverse(category.views.category_list)

但这可以正常工作:

>>> reverse("category_list_name")
u'/en/category/list/'

一个视图,我得到一个空字符串来扭转命名的url。
像你看到我也在使用localeurl,但是我认为这不应该重要吗?

In a view, I get an empty string for reversing the named url. Like you see I'm also using localeurl, but I think that shouldn't matter?

任何想法?

推荐答案

{%url'category_list_name'%} 看起来像是使用Django 1.3,但是你有<$您的模板中的c $ c> {%从未来%}加载url 如果不是,您应该使用 {%url category_list_name%} 。报价有所不同。

{% url 'category_list_name' %} looks like you are using Django 1.3 but do you have {% load url from future %} in your template? If not you should use {% url category_list_name %} instead. Quotes make all the difference.

这篇关于另一个django NoReverseMatch的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆