简体   繁体   中英

Named url with kwargs issue

Can anyone explain to me what is happening here? In the same template I have the following:

<a href="{% url 'triage' group_id=group.id as group_url %}{{ group_url }}">Group</a>
<a href="{% url 'triage' group_id=group.id %}">Group</a>

The top url works fine while the bottom errors out the entire page with:

Reverse for 'triage' with arguments '()' and keyword arguments '{u'group_id': 7}' not found. 0 pattern(s) tried: []

Any ideas?

The documentation mentions that:

This {% url ... as var %} syntax will not cause an error if the view is missing.

That is why the 1st view errors out the page while the second one works.

In any case, probably there is an error in your url pattern - can you show us your urls.py ?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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