在save
我的项目模型的方法中,我需要将实例保存在数据库中,以便根据某个数量计算排名:
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)
它似乎有效,但我想确保不会产生不良影响。这样做可以吗?