Jinja2 url generation

<a href="{{ url('affiliate', affiliate=object.slug) }}">{{ object.name }} </a> 

Cause an error: reverse() got an unexpected keyword argument 'affiliate'

Upvotes: 1

Views: 4017

Answers (1)

Alex Morozov
Alex Morozov

Reputation: 5993

As your url() function seem to be an alias to the Django's reverse(), the function signature is different from the regular template tag. So just use the reverse() syntax:

<a href="{{ url('affiliate', args=[object.slug]) }}">{{ object.name }}</a>

Upvotes: 5

Related Questions