Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/287.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 其中';s django的循环值取自?_Python_Django - Fatal编程技术网

Python 其中';s django的循环值取自?

Python 其中';s django的循环值取自?,python,django,Python,Django,当我们在django中使用for loop时,该列表从何而来 django的例子如下: {运动员列表中运动员的百分比%} {{atternate.name} {%endfor%} 没有解释运动员名单的来源。什么东西在传递数组的值?我已经通过了django的官方教程,并设法使其生效。但是,我不明白这一点。(本教程也没有解释它的来源) 很抱歉出现了noobs问题…在本教程中,这相当于本节中的“最新问题列表” 正如其他答案所述,您应该遵循教程的所有页面。如果你不这样做,你可能不会用更好、更简单的

当我们在django中使用
for loop
时,该列表从何而来

django的例子如下:

    {运动员列表中运动员的百分比%}
  • {{atternate.name}
  • {%endfor%}
没有解释运动员名单的来源。什么东西在传递数组的值?我已经通过了django的官方教程,并设法使其生效。但是,我不明白这一点。(本教程也没有解释它的来源)


很抱歉出现了noobs问题…

在本教程中,这相当于本节中的“最新问题列表”


正如其他答案所述,您应该遵循教程的所有页面。如果你不这样做,你可能不会用更好、更简单的方式来做事情(并让你的问题被否决)。

你的观点有它可以使用的上下文。试着阅读

视图的本质是:

context = Context({
    'someVar': someValue
})
return render(request, 'index.html', context)
<html>
    <body>
        <span>this is the value: {{someVar}}</span>
    </body>
</html>
该模板如下所示:

context = Context({
    'someVar': someValue
})
return render(request, 'index.html', context)
<html>
    <body>
        <span>this is the value: {{someVar}}</span>
    </body>
</html>

这是值:{someVar}}

它来自视图,就像模板上下文中的所有变量一样。这与for循环没有任何关系。您需要阅读教程!第二(或第三)页包含有关此的信息。看起来你需要做整件事!