I can't use the partner's answer because I use django version < 1.9, for me the solution was the one found in the following link (don't forget to like Shang Wang if it worked for you): Put the result of simple tag into a variable
As our friend Shang says, you must create a method with the assignment_tag decorator, this way we can save the response in a method and consume it from the template:
@register.assignment_tag(takes_context=True)
def precio_format_with_locale_assignment(context, cantidad):
locale = context.dicts[1]["locale"]
reserva = context.dicts[1]["reserva"]
return format_price_with_locale(reserva, cantidad, locale)
As you can see I added (takes_context=True) to access to the context as in a simple_tag.
And to use it in the template:
{% precio_format_with_locale_assignment interval.amount as interval_amount %}
{% blocktrans with date=interval.date trimmed %}
Desde el {{ date }}: se cobrarĂ¡n {{ interval_amount }}.
{% endblocktrans %}