Created
January 10, 2012 22:55
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyModel(models.Model): | |
... | |
def save(self, *args, **kwargs): | |
if self.pk: | |
old_version = self.__class__.objects.get(pk=self.pk) | |
# Now we have self and old_version, which are different | |
# instances of the same object. | |
if old_version.foo_field != self.foo_field: | |
# foo_field is changed, do stuff. | |
super(MyModel, self).save(*args, **kwargs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment