I have created a simple tag as below.
@register.simple_tag(takes_context=True,name="calculate_billamount")
def calculate_billamount(quantity,unitprice):
return (quantity * unitprice)
{% for order_detail in order_details %}
{% if order_detail.orderid == order %}
<tr>
<td>{{order_detail.productid.productname}}</td>
<td>{{order_detail.unitprice}}</td>
<td>{{order_detail.quantity}}</td>
<td>{% calculate_billamount quantity=5 unitprice=4 %} </td>
<td>{{billamount}}</td>
</tr>
{% endif %}
{% endfor %}
This is just multiplying 2 numbers and returning the result.
I am trying to use above simple tag inside a FOR and IF as shown below.
I am getting below error. enter image description here
when i try this individually, i am not getting any error i.e. it is working fine.
<div>
{% calculate_billamount quantity=5 unitprice=4 %}
</div>
Is there any restriction, that we cant use Custom Simple Template tags inside django built in template tags like for and if?
Thanking you.
{% load custom_tags %} needs to be placed in both html pages.
My Scenario :
First.html -> is using {%show_orders%} template tag which is displaying results in Second.html with the help of Inclusiontag.
Now when I try to use "Calculate_billamount" custom tag in second.html, it was giving an error. So i had to put {% load custom_tags %} in Second.html too.
Thank you all.