Skip to content

Instantly share code, notes, and snippets.

@pirate
Created August 3, 2016 20:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pirate/ea97440bac8fa7a00b3ff55d67eb37e7 to your computer and use it in GitHub Desktop.
Save pirate/ea97440bac8fa7a00b3ff55d67eb37e7 to your computer and use it in GitHub Desktop.
def save(self, *args, **kwargs):
if self.id:
on_disk = Game.objects.get(pk=self.id)
if on_disk.modified > self.modified:
raise StaleWriteError('Tried to save outdated Game')
super(Game, self).save(*args, **kwargs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment