我用谷歌搜索但无法找到解决方案。我去的地方想到了一些答案,例如这个答案
我通过Trans Tag 内置标签阅读的一些官方文档
模板视图
{% 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 过滤器。没有工作。