-
-
Save maxwellamaral/b3b956b4dd8fdda2face1ae3f37571e5 to your computer and use it in GitHub Desktop.
Django: detectando mudanças nos campos do model
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
def save(self, *args, **kwargs): | |
# Detectando mudanças em alguns campos | |
old = Notification.objects.filter(pk=getattr(self, 'pk', None)).first() | |
if old: | |
# Se o campo number tiver sido modificado, limpar os campos | |
if old.number != self.number: | |
self.file = None | |
self.download_success = False | |
self.download_date_time = None | |
self.log = '' | |
super(Notification, self).save(*args, **kwargs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment