Django 模板查找?

Django template looks up?

我正在寻找有关 django 教程的解释 here,尤其是它所说的模板部分:

The template system uses dot-lookup syntax to access variable attributes. In the example of {{ question.question_text }}, first Django does a dictionary lookup on the object question. Failing that, it tries an attribute lookup – which works, in this case. If attribute lookup had failed, it would’ve tried a list-index lookup.

它怎么可能对 Question 对象进行字典、属性和列表索引查找? 如果我的 Question 对象包含一个列表,我将创建一个属性 list 并为其设置值。所以它只会是一个属性 lookup ? 我觉得我有什么没看懂... 谢谢

它没有,但模板直到尝试才知道。文档试图说明的要点是模板将尝试所有三种查找,以便您可以传递字典、对象或列表并以相同的方式访问它们。