django template {% url %}

24 views
Skip to first unread message

颜刚

unread,
Apr 4, 2016, 9:36:36 AM4/4/16
to Django users
i have this code in my template:

{% for i in var %}
{% for action in actions %}
<li>
    <a href="{% url action.url_alias %}">{{ action.name_short }}</a>
</li>
{% endfor %}
{% endfor %}

the value of action.url_alias is  'user-edit' i.id host 'account' ,that's what i want from table,i use django-hosts in my project,the error is that:

Reverse for ''user-edit' i.id host 'account'' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []

but when i use the value  'user-edit' i.id host 'account' directly in {%%} like this {% url  'user-edit' i.id host 'account' %},that's ok.
the i.id is one of another for loop's value.how can i do this,thanks for help.

Reply all
Reply to author
Forward
0 new messages