我有一个嵌套的for循环,其中内循环的对象列表由外循环填充
模板
{% for currency in currencies %}
{% for transaction in transactions_{{currency}} %}
//content here
{% endfor %}
{% endfor %}
View.py
currencies = ['usd', 'inr']
context['currencies'] = currencies
for currency in currencies:
context['transactions_'+currency] = access.listtransactions(self.request.user.username)
我需要的是内循环翻译如下
{% for currency in currencies %}
// {{currency}} iterates to usd
{% for transaction in transactions_usd %}
目前我收到以下错误
TemplateSyntaxError at /transaction/
Could not parse the remainder: '{{currency}}' from 'transactions_rcv_{{currency}}'
我有什么遗漏或替代功能吗?任何指导都将不胜感激。