Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Custom save method for preventing resaving model object in database

  • Loading branch information...
commit 104ddb133e3ca053210442553835eca565692aae 1 parent d296c12
@kachayev authored
Showing with 7 additions and 0 deletions.
  1. +7 −0 gearoscope/apps/monitor/models.py
View
7 gearoscope/apps/monitor/models.py
@@ -43,3 +43,10 @@ class Revision(models.Model):
# last revision from other revision object (in this case AttributeError) will be raised
last = LastRevision()
+ # Prevent resaving changed revision object
+ # This means, that once create revision can not be
+ # saved in database second time
+ def save(self, *args, **kwargs):
+ if self.id is None:
+ super(Revision, self).save(*args, **kwargs)
+
Please sign in to comment.
Something went wrong with that request. Please try again.