Django Book 翻译
菜单>:
TOC
返回
原文:
The problem has to do with when the queries in ``extra_context`` are evaluated. Because this example puts ``Publisher.objects.all()`` in the URLconf, it will be evaluated only once (when the URLconf is first loaded). Once you add or remove publishers, youll notice that the generic view doesnt reflect those changes until you reload the Web server (see Caching and QuerySets in Appendix C for more information about when QuerySets are cached and evaluated).
翻译:
我们现在来看一下, ``extra_context`` 里包含数据库查询的问题。因为在这个例子中,我们把 ``Publisher.objects.all()`` 放在URLconf中,它只会执行一次(当URLconf第一次加载的时候)。当你添加或删除出版商,你会发现在重启Web服务器之前,通用视图不会反映出这些修改的(有关QuerySet何时被缓存和赋值的更多信息请参考附录C中“缓存与查询集”一节)。
备注:
译者: