问题
<a href="{{ url('affiliate', affiliate=object.slug) }}">{{ object.name }} </a>
Cause an error: reverse() got an unexpected keyword argument 'affiliate'
回答1:
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>
来源:https://stackoverflow.com/questions/34712469/jinja2-url-generation