📅  最后修改于: 2022-03-11 14:45:48.281000             🧑  作者: Mango
# override create model method (django)
class MyModel(models.Model):
name = ....
........
.......
def save(self, *args, **kwargs):
if not self.pk:
# This code only happens if the objects is
# not in the database yet. Otherwise it would
# have pk
# -- do your custom actions here --
super(MyModel, self).save(*args, **kwargs) # activate the default method on update