Created
October 29, 2011 21:01
-
-
Save valyagolev/1325091 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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