[Answer]-Django tag for relative urls

1đź‘Ť

âś…

Template files are not Python. Thus, you can’t do the tuple thing with your arguments. Instead, refactor the template tag to take this type of syntax:

{% url_for link params='website homepage' %}

Then you have to account for that when parsing the bits variable in the template tag.
It ultimately comes down to parsing strings.

The docs:

https://docs.djangoproject.com/en/dev/howto/custom-template-tags/#writing-the-compilation-function

See the notes for “token.contents” and “token.split_contents()”.

Leave a comment