Django Book 翻译
菜单>:
TOC
返回
原文:
Inside the ``{% for %}`` block, the existing variables are moved out of the way to avoid overwriting the magic ``forloop`` variable. Django exposes this moved context in ``forloop.parentloop`` . You generally dont need to worry about this, but if you supply a template variable named ``forloop`` (though we advise against it), it will be named ``forloop.parentloop`` while inside the ``{% for %}`` block.
翻译:
在一个 ``{% for %}`` 块中,已存在的变量会被移除,以避免 ``forloop`` 变量被覆盖。Django会把这个变量移动到 ``forloop.parentloop`` 中。通常我们不用担心这个问题,但是一旦我们在模板中定义了 ``forloop`` 这个变量(当然我们反对这样做),在 ``{% for %}`` 块中它会在 ``forloop.parentloop`` 被重新命名。
备注:
译者: