【发布时间】:2014-06-06 15:16:23
【问题描述】:
我有这个词典
# Views.py
results = {}
# Set content types
results["teams.team"] = []
results["users.userprofile"] = []
for result in sqs:
content_type = result.content_type() # teams.team , users.userprofile, ...
results[content_type].append(result.get_additional_fields()) # get_additional_fields => {title:"" , ... }
如何在 django 模板中显示 team.team 大小?
我试过{{ results.user.userprofile.count }} 但似乎. 出错了。
谢谢
【问题讨论】:
-
我已经更新了我的答案。希望对你有帮助
-
你的意思是要获取
"teams.team"中的列表长度? -
是的,但只在模板中,并且
{{ results['users.userprofile'].count给出Could not parse the remainder错误
标签: python python-2.7 django-templates django-views