1
从字典检索值我有以下情况:我正在寻找一个快速的方式在模板
{% if accounts.count > 0 %}
{% for account in accounts %}
<div>Balance:<b>{{ my_dict.account.id }}</b></div>
<div><a href="/edit/{{ account.id }}"><button>Edit</button></a></div>
{% endfor %}
{% else %}
<p>...</p>
{% endif %}
。
这样的安排是好的
my_dict.account
但我会做这样的事情。我有两个点
my_dict.account.id
有没有办法做到这一点?这是创建模板一个变量是个好主意,但它不为我工作
那么my_dict是什么? – ozgur
[Django模板如何用变量查找字典值]的可能重复(http://stackoverflow.com/questions/8000022/django-template-how-to-look-up-a-dictionary-value-with -a-variable) – Geotob
我不想创建自己的过滤器。所以这不是一回事 – programmerJavaPL