Ali Raza
Ali Raza

Reputation: 1063

Django how to add 2 or more filters

How to add multiple filters in Django

{{ order.get_cart_total | add:500 | floatformat:2 }}

Upvotes: 2

Views: 141

Answers (1)

willeM_ Van Onsem
willeM_ Van Onsem

Reputation: 476659

You add these in a "chain", where the output of the first filter is filtered again, so:

{{ order.get_cart_total|add:500|floatformat:2 }}

That being said, It might be better to add 500 to the result in the get_cart_total method of the order, or in another method. A template is normally used to specify how data is rendered, business logic is normally written in the models and in the views.

Upvotes: 3

Related Questions