Home > Mobile >  How to do a subtraction in a html page on a pyhton variable?
How to do a subtraction in a html page on a pyhton variable?

Time:11-03

I have this model:

class Canva(models.Model):

name = models.charfield(...

year = models.IntegerField(...

In my html page, When I use {{ canva.year }}, it shows me the year correctly.

how can I see the year before, I tried {{ canva.year-1 }} or {{ canva.year }}-1 and it doesn't seem to work.

CodePudding user response:

you can simply do

{{canva.year|add:"-1" }}

or you can create your custom_tempalte tag to subtract values

  • Related