Skip to content

Commit a6aabfd

Browse files
ercpeJohann Schmitz
and
Johann Schmitz
authored
#38 Check type before updating version field (#39)
Application may already use `reversion` but not implement `HandleRefModel` in every model under control of reversion. Check the objects type before updating the `version` field. Co-authored-by: Johann Schmitz <johann.schmitz@dc1.com>
1 parent b7af826 commit a6aabfd

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/django_handleref/models.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88

99
def handle_version(**kwargs):
1010
for vs in kwargs.get("versions"):
11-
instance = vs.object
12-
instance.version = instance.version + 1
13-
instance.save()
11+
if isinstance(vs.object, HandleRefModel):
12+
instance = vs.object
13+
instance.version = instance.version + 1
14+
instance.save()
1415

1516
reversion.signals.post_revision_commit.connect(handle_version)
1617
except ImportError:

0 commit comments

Comments
 (0)