Jinja2网址生成 [英] Jinja2 url generation
本文介绍了Jinja2网址生成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<a href="{{ url('affiliate', affiliate=object.slug) }}">{{ object.name }} </a>
引起错误: reverse()收到了意外的关键字参数'affiliate'
Cause an error: reverse() got an unexpected keyword argument 'affiliate'
推荐答案
由于您的url()
函数似乎是Django reverse()
的别名,因此该函数签名与常规模板标记不同.因此,只需使用reverse()
语法:
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>
这篇关于Jinja2网址生成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文