class MyModel(models.Model):
...
def save(self):
super(DocumentTemplate, self).save(*args, **kwargs)
# retrieve the old version of the object
try:
old = DocumentTemplate.objects.get(id=self.id)
except MyModel.DoesNotExist:
# object is being created
customize_function_create(self)
# check if something has changed
if self.interesting_field != old.interesting_field:
# the field has been changed
customize_function_update(self)
return
models.py
:相关问题 更多 >
编程相关推荐