嵌套的 Django 标签 [英] Nested Django tags
本文介绍了嵌套的 Django 标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用二维码 (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屋!
查看全文