Skip to content

Commit d61ace7

Browse files
authored
Update changes.py
1 parent 1cc9c14 commit d61ace7

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

django_model_changes/changes.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ def __init__(self, *args, **kwargs):
7676
dispatch_uid='django-changes-%s' % self.__class__.__name__
7777
)
7878

79+
def _state_fields(self):
80+
return [f for f in self._meta.get_fields() if f.concrete and not f.many_to_many]
81+
7982
def _save_state(self, new_instance=False, event_type='save'):
8083
# Pipe the pk on deletes so that a correct snapshot of the current
8184
# state can be taken.
@@ -100,8 +103,8 @@ def current_state(self):
100103
Returns a ``field -> value`` dict of the current state of the instance.
101104
"""
102105
field_names = set()
103-
[field_names.add(f.name) for f in self._meta.local_fields]
104-
[field_names.add(f.attname) for f in self._meta.local_fields]
106+
[field_names.add(f.name) for f in self._state_fields()]
107+
[field_names.add(f.attname) for f in self._state_fields()]
105108
return dict([(field_name, getattr(self, field_name, None)) for field_name in field_names])
106109

107110
def previous_state(self):

0 commit comments

Comments
 (0)