Django 模板未从数据库加载
我正在将模板更改为新设计。在此过程中,类别列表停止加载。
“category_list 有 2 个参数”</p>
在 html 文件中,“category_list”正在加载:
{% category_list request.path %}
有人可以解释在这种情况下“接受 2 个参数”是什么意思吗?
编辑:这是自定义模板标签:
def category_list(request_path):
list_cache_key = 'active_category_link_list'
active_categories = cache.get(list_cache_key)
if not active_categories:
active_categories = Category.active.all()
cache.set(list_cache_key, active_categories, CACHE_TIMEOUT)
return {
'active_categories': active_categories,
'request_path': request_path
}