73101/how-to-do-math-in-a-django-template
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.
Hello @kartik,
You can use the add filter:
{{ object.article.rating_score|add:"-100" }}
Thank You!!
Hello @kartik, Your query appears to have a ...READ MORE
Hello @kartik, In the case of the JSON ...READ MORE
Hello @kartik, Use Dictionary Items: {% for key, value ...READ MORE
Hello @kartik, In your profile model provide related_name user ...READ MORE
Hi, there is only that way and ...READ MORE
Hi all, with regard to the above ...READ MORE
Hello @kartik, To turn off foreign key constraint ...READ MORE
Hello @kartik, Let's say you have this important ...READ MORE
Hello @kartik, You cannot call a function that ...READ MORE
Hello @kartik, Use linebreaks or linebreaksbr filter: {{ text|linebreaks }} Or surround the text ...READ MORE
OR
At least 1 upper-case and 1 lower-case letter
Minimum 8 characters and Maximum 50 characters
Already have an account? Sign in.