Pass {% url %} to custom template tag in Django

django, django-templates

Solution

Simple url tag supports assignment.

{% url 'myview' as my_url %}
{% my_tag arg1 my_url arg3=5 %}

Problem

I'm developing a custom Django template tag that requires multiple arguments. One of those arguments is a URL. When I try to do this: ``` {% my_tag arg1 {% url "myview" %} arg3=5 %} ``` I get the following template syntax error: `Could not parse the remainder: '{%' from '{%'` How can I pass a URL to a custom template?

Original source