擅长:python、mysql、java
<p>要访问模板中的变量,它必须位于用于呈现该模板的上下文中。我猜在呈现模板时,不会将上下文字典传递给模板。</p>
<p><a href="http://docs.djangoproject.com/en/dev/topics/http/shortcuts/#render-to-response" rel="noreferrer">http://docs.djangoproject.com/en/dev/topics/http/shortcuts/#render-to-response</a></p>
<p>引用的“dictionary”有一个dictionary,它包含您希望在上下文中有可用的所有变量。例如:</p>
<pre><code>return render_to_response('your_template.html', {'h': h})
</code></pre>
<p>至于“没有错误”的错误。。。这是无效模板变量的默认设置。如果愿意,可以在项目的设置中更改此设置。</p>
<p><a href="http://docs.djangoproject.com/en/dev/ref/settings/#template-string-if-invalid" rel="noreferrer">http://docs.djangoproject.com/en/dev/ref/settings/#template-string-if-invalid</a></p>