Monday, April 4, 2016

django template {% url %}

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.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/c613ac62-4a4d-4ff0-8dae-7b3243fb46ab%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment