Ticket #11007: modelchanges.patch
File modelchanges.patch, 848 bytes (added by , 16 years ago) |
---|
-
django/db/models/base.py
593 593 594 594 def prepare_database_save(self, unused): 595 595 return self.pk 596 597 def changes(self): 598 fields = [x.name for x in self._meta._fields() if not (x.name.endswith('_ptr_id') or x.name.endswith('_ptr'))] 599 if not self.pk: 600 return dict([(x, (None, getattr(self, x))) for x in fields]) 601 old = self.__class__.objects.get(pk=self.pk) 602 return dict([(x, (getattr(old, x), getattr(self, x))) for x in fields if getattr(self, x) != getattr(old, x)]) 596 603 597 598 604 ############################################ 599 605 # HELPER FUNCTIONS (CURRIED MODEL METHODS) # 600 606 ############################################