What's the best practice to update a field automatically?
You never write things like this to a database, instead you store the date of birth / origin and then work out the age as when its needed.
The extra time involved in this calculation is so minimal that it will most likely never be the performance issue in your code.
Here's what I want to accomplish: I have an 'age' field in my model which I'd like its value to be the time duration up til now - and I mean now as in real time, not just the obj creation time or updated time.
At first I was wondering if there's some kind of a dynamic field in django that the field value would just keep updating based on a formula. But then I figured that wasn't realistic, it has to be updated by something at some point in time.
Right now what comes on my mind is to write a model method to calculate the value and assign it to the field, and to manually calls it and write the new value to the field everytime before the query of the class objects.
I wonder is there any better way to accomplish this since my method will add some loading to the database which might just be unnecessary.
Thanks for your help.