嵌套的Django标签 [英] Nested Django tags
本文介绍了嵌套的Django标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用QR码(Django)库,当我执行 {%qrcode_from_text {%url'foo'%} l%}
时,内部标记给出错误。有什么办法可以做这种嵌套的Django模板标签吗?谢谢。
I am using the QR code (Django) library and when I do {% qrcode_from_text "{% url 'foo' %}" "l" %}
, the inner tag gives error. Is there any way to do such nested django template tags? Thanks.
推荐答案
不,但是您不需要。 url
标记具有将结果保存到变量的语法:
No, but you don't need to. The url
tag has a syntax to save the result to a variable:
{% url 'foo' as foo_url %}
然后您可以在自定义标记中使用它:
and you can then use that in your custom tag:
{% qrcode_from_text foo_url %}
这篇关于嵌套的Django标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文