【发布时间】:2016-03-02 11:09:52
【问题描述】:
问题是header.html 部分总是包含保存在数据库中的类别字典。包括这个带参数的部分
{% include "_partials/header.html" with categories %}
每次渲染局部时我都需要传递类别字典
render("index.html", {"flowers":flowers, "categories":categories})
render("details.html", {"flower":flower, "categories":categories})
...
有什么解决方案,header.html partials 总是包含categories 字典。
【问题讨论】:
-
^ 您可以创建自己的中间件,以便将其包含在您的请求中。还有context processors