42👍
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 }}
.
👤Erik
- [Django]-How to get a favicon to show up in my django app?
- [Django]-Adding to the "constructor" of a django model
- [Django]-Combining Django F, Value and a dict to annotate a queryset
21👍
Generally it is recommended you do this calculation in your view. Otherwise, you could use the add filter.
👤bdd
- [Django]-How do I use an UpdateView to update a Django Model?
- [Django]-Django TypeError: get() got multiple values for keyword argument 'invoice_id'
- [Django]-Django :How to integrate Django Rest framework in an existing application?
Source:stackexchange.com