Hey, A filter would work better here if you can use one. The following should work:
Defined as: @register.filter def encode_url(link_text): return link_text.replace(' ', '_') And in template: {% with state_url=flow.state.description|encode_url %} <a href="{% url 'advance-flow' flow.id state_url %}">advance</a> {% endwith %} Aubrey On Thu, Oct 30, 2014, at 03:23 PM, Daniel Grace wrote: > Hi, I am trying to use the url tag on some parameters, one of which > needs to come from a function. For example as follows: {% with > state_url=encode_url flow.state.description %} <a href="{% url > 'advance-flow' flow.id state_url %}">advance</a> > > encode_url is defined as follows: @register.simple_tag def > encode_url(link_text): return link_text.replace(' ', '_') > > This causes an error on the with statement: Request Method:GET Request > URL:http://127.0.0.1:8000/list_flows/ Django Version:1.7 Exception > Type:TemplateSyntaxError Exception Value: 'with' received an invalid > token: 'flow.state.description' > > I'm guessing that you cannot put another template tag in the "with" > statement. I cannot see a way around this. Any ideas? > > Thanks > -- 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+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/1414812157.1469526.185763229.243C3457%40webmail.messagingengine.com. For more options, visit https://groups.google.com/d/optout.