The problem
I have a field in my model that requires some calculation. I want to perform these calculations when the model is saved. However, because it is resource intensive, I want to only perform these calculations when certain fields have changed.
Initial thought
Keep the hash of the 3 fields as a different field in the model. On save, hash the three fields and, if equal to the the one currently saved in the model, continue on saving the instance without further work. Otherwise, perform calculations, save the results of the calculation and save new hash.
My questions:
Is this the best option? If not, please share what would be better and why.
If there isn't a better way: Which kind of hash should I use? And why?
Which kind of Django model field type should I use to save the hash?