擅长:python、mysql、java
<p>编写您自己的呈现方法不要重复该代码。然后在需要呈现模板时调用它。</p>
<pre><code>def render_with_dict(template):
mydict = code_to_generate_dict()
return render_template(template, mydict=mydict)
def myview():
return render_with_dict('main_page.html')
</code></pre>