I want to do this:
100 - {{ object.article.rating_score }}
So for example, the output would be 20
if {{ object.article.rating_score }}
equaled 80
.
How do I do this at the template level? I don't have access to the Python code.
Use django-mathfilters. In addition to the built-in add filter, it provides filters to subtract, multiply, divide, and take the absolute value. For the specific example above, you would use {{ 100|sub:object. article.
You can use the add
filter:
{{ object.article.rating_score|add:"-100" }}
Use django-mathfilters. In addition to the built-in add filter, it provides filters to subtract, multiply, divide, and take the absolute value.
For the specific example above, you would use {{ 100|sub:object.article.rating_score }}
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With