[Solved]-Django template, send two arguments to template tag?

31👍

From my point of view it looks easier to use a simple tag instead of a template filter so you can call it without needing to send a string.

https://docs.djangoproject.com/en/1.10/howto/custom-template-tags/#simple-tags

Your template would be just:

{% load remaining_cost %}
{# Don't forget to load the template tag as above #}

<th>{% remaining_cost item.cost_per_month item.install_date item.comtract_length %}</th>

and the template tag would be:

@register.simple_tag
def remaining_cost(cost_per_month, install_date, contract_length):
    cost = contract_remainder(install_date, contract_length) * cost_per_month
    return cost 

Leave a comment