Skip to content

Instantly share code, notes, and snippets.

@valyagolev
Created October 29, 2011 21:01
Show Gist options
  • Save valyagolev/1325091 to your computer and use it in GitHub Desktop.
Save valyagolev/1325091 to your computer and use it in GitHub Desktop.
class EntityItself(models.Model):
"""Все что мы хотим от нее - уникальный PrimaryKey"""
def current_state(self):
return self.entitystate_set.latest()
def __getattr__(self, attr):
return getattr(self.current_state(), attr)
class EntityState(models.Model):
entity = models.ForeignKey(EntityItself)
version = models.DateTimeField()
title = models.CharField()
# ... everything else
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment