Арифметические операции в шаблоне django
\<tr\>
{% for i in portfolio %}
\<!-- \<th scope="row"\>{{i.id}}\</th\> --\>
\<td\>{{ i.stock }}\</td\>
\<td\>{{ i.quantity }}\</td\>
\<td\>{{ i.purchasedPrice }}\</td\>
\<td\>{{ i.currentPrice }}\</td\>
\<td\>{{ i.quantity\*i.currentPrice - i.quantity\*i.purchasedPrice|safe }\</td\>
\<td\>\</td\>
\</tr\>
{% endfor %}
Я хочу отобразить полученные результаты mongodb в приведенном выше формате, но
<td>{{ i.quantity*i.currentPrice - i.quantity*i.purchasedPrice|safe }</td>
Эта строка кода вызывает ошибку "TemplateSyntaxError at /. Could not parse some characters: i.quantity|i.currentPrice - i.quantityi.purchasedPrice||safe"
Как это можно исправить?