【发布时间】:2020-09-30 03:00:20
【问题描述】:
我用谷歌搜索但找不到解决方案。我去的地方想到了一些答案,例如This answer
我浏览过的一些官方文档Trans TagBuilt-In Tags
模板视图
{% load custom_tags %}
{% for each in content %}
{% with tempID='' %} # It is initially empty string
{% if each.contentID != tempID %}
{% tempID = each.contentID %} # Want to assign new value to tempID
....
..
{% endif %}
{% endwith %}
{% endfor %}
是否有任何方法可以分配标签变量。我也尝试了 custom_tags 过滤器。没用。
【问题讨论】:
标签: python html django django-template-filters django-custom-tags