I have a field in my model
Step=models.IntegerField()
I call it normally in the template with the following:
{{user.step}}
Now I want this field to automatically increase after every year
What is the best approach here?
I have a field in my model
Step=models.IntegerField()
I call it normally in the template with the following:
{{user.step}}
Now I want this field to automatically increase after every year
What is the best approach here?
Is it based on some timestamp? like a birth date?
In this case you have few option:
Make it a property and recalculate it before sending data to template
from dateutil.relativedelta import relativedelta
@property
def step(self):
return relativedelta(datetime.now(), self.timestamp).years
Make cronjob that will update step field every day using method above