mirror of
https://github.com/Hopiu/django-model-utils.git
synced 2026-05-19 07:11:07 +00:00
Fix return value of ModelTracker.current pre-save
This commit is contained in:
parent
1ae2effc22
commit
45ac3bd03f
1 changed files with 5 additions and 3 deletions
|
|
@ -44,11 +44,13 @@ class ModelInstanceTracker(object):
|
|||
self.fields = fields
|
||||
|
||||
def set_saved_fields(self):
|
||||
self.saved_data = self.current()
|
||||
if self.instance.pk:
|
||||
self.saved_data = self.current()
|
||||
else:
|
||||
self.saved_data = {}
|
||||
|
||||
def current(self):
|
||||
return (dict((f, getattr(self.instance, f)) for f in self.fields)
|
||||
if self.instance.pk else {})
|
||||
return dict((f, getattr(self.instance, f)) for f in self.fields)
|
||||
|
||||
def has_changed(self, field):
|
||||
"""Returns ``True`` if field has changed from currently saved value"""
|
||||
|
|
|
|||
Loading…
Reference in a new issue