Django Book 翻译
菜单>:
TOC
返回
原文:
The solution is to use a callback in ``extra_context`` instead of a value. Any callable (i.e., a function) thats passed to ``extra_context`` will be evaluated when the view is rendered (instead of only once). You could do this with an explicitly defined function:
翻译:
解决这个问题的办法是在 ``extra_context`` 中用一个回调(callback)来 代替使用一个变量。任何可以调用的对象(例如一个函数)在传递给 ``extra_context`` 后都会在每次视图渲染前执行(而不是只执行一次)。 你可以象这样定义一个函数:
备注:
译者: