简体   繁体   English

NoReverseMatch Django错误多个URL相同的方法

[英]NoReverseMatch django error multiple URLs same method

error message: 错误信息:

ExceptionType: NoReverseMatch
Exception Value: Reverse for 'darts.teams.views.expanded_details' with arguments '(u'RightFlights',)' and keyword arguments '{}' not found.

in the template: 在模板中:

<a href="{{ lib.url(expanded_details, team.name) }}" class="btn btn-cog">Expanded Details</a>

in urls.py 在urls.py中

urlpatterns = patterns('darts.teams.views',
    url(r'^(?P<teamname>.*?)/expanded_details/$', 'team_details', {'expanded': True}, "expanded_details"),
    url(r'^(?P<teamname>.*?)/details/$', 'team_details', name="team_details"),

    url(r'^(?P<teamname>.*?)/add_player/$', 'team_add_player', name="team_add_player"),
    url(r'^(?P<teamname>.*?)/add_player/confirm/$', 'team_add_player',"team_add_player_confirm"),
)

The additional URLs in urls.py all render fine, but the 'expanded_details' one is throwing the error. urls.py中的其他URL都可以正常显示,但是'expanded_details'引发了错误。

Why is this one different than the others? 为什么这与其他不同? Am I missing something blatant? 我是否缺少明显的东西?

update 更新

The error says "Reverse for 'darts.teams.views.expanded_details' failed", but it should be 'darts.teams.views.team_details' or 'expanded_details' . 该错误显示“对'darts.teams.views.expanded_details'反向失败”,但应为'darts.teams.views.team_details''expanded_details' The first form is the path to view, the latter is the name of the named URL. 第一种形式是查看的路径,后一种形式是命名URL的名称。
You could check the value of expanded_details inside the templatetag to ensure it is resolved to one of the correct values above, or follow slackjake's suggestion: use 'expanded_details' (note the single quote) directly. 您可以检查的价值expanded_details的templatetag内,以确保它上面的解析为正确的值中的一个,或者按照slackjake的建议:用'expanded_details'直接(注意是单引号)。


(?P<teamname>.*? is invalid, maybe you mean (?P<teamname>.*?) ? (?P<teamname>.*?无效,也许您是说(?P<teamname>.*?)
Also, what does lib.url do? 另外, lib.url什么作用?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM