Django 模板标签可以访问字符串变量但不能调用 table 函数?

Django template tag can access string variable but can't call a table function?

根据 https://docs.djangoproject.com/en/2.2/ref/templates/language/,只要不带参数,您应该能够从标签调用函数。 我试过这个:

class TaskTable(Table):
    test = "test"
    def give_aids():
        return "aids"
    def give_tuple():
        return ('y', 'e', 'e', 't',)
    class Meta:
        template_name = 'some_template.html'

然后,在相应的模板文件中,我尝试像这样访问这些。

{{table.test}}
{{table.give_aids}}
{% for char in table.give_tuple %}
{{char}}
{% endfor %}

渲染模板时显示 "test",而 "aids" 和 "yeet" 不显示。我做错了什么?

这就是我在 python 做猴子的收获。我没有将 "self" 传递给方法。抱歉浪费你的时间 xD