In the save method of my Item model, I need the instance to be saved in the DB in order to compute a ranking according to some quantity:
def save(self, *args, **kwargs):
super(Item, self).save(*args, **kwargs)
# get all the Item instances, order and get the ranking of the current instance
self.ranking = ranking
super(Item, self).save(*args, **kwargs)
It seems to work, but I’d like to be sure to get no undesirable effects. Is that ok to do that?
I don’t think this will have any negative effects, but another approach would be just to update the ranking and not save the whole model. You can do that like this: