重复问题解释了“语境”的含义,而不是解释为什么它与现实生活中的原意相矛盾。 我们将使用“内容”代替。你知道吗
Django文档将“上下文”定义为:
Context:A dict to be used as the template’s context for rendering.
MB将其定义为:
the parts of a discourse that surround a word or passage and can throw light on its meaning
他们互相矛盾。你知道吗
举个例子来解释我的问题:
In views.py
context = {key:value}
render(request, template_name, context)
in template
<p> The parts of a discourse that surround a
word {{ key }} and can throw lights on its meaning.<\p>
字面上,“上下文”是花括号外的部分,而不是要填充的内部部分。你知道吗
现在,django的上下文是括号内的部分。你知道吗
如何理解Django中语境的定义?你知道吗
“背景”是提交背景调查的“背景信息”
将上下文视为解析模板的环境。因此,当模板中有类似
{{ key }}
的内容时,模板引擎会在上下文中查找它正在执行的内容,以找到要插入的值。你知道吗上下文“包围”模板并“赋予其意义”。你知道吗
相关问题 更多 >
编程相关推荐