On Feb 11, 11:23 pm, iliveinapark <iliveinap...@brentonannan.com> wrote: > Gday all, > > I'm trying to find a way to have changes made to a model object > require approval before becoming the live data on my site. I had > thought about cloning the object, and having the clone stored as a > draft, but making it live would require either swapping all the data > from the draft to the original object, or changing all references to > the original to reference the draft instead. > > Does anyone have any ideas on a nice way to do this
class MyModel(models.Model): # unversionned fields lives here def published_revision(self): try: return self.revisions.published()[0] except IndexError: return None class MyModelRevisionManager(models.Manager): use_for_related_fields = True def published(self): return self.filter(published=True) class MyModelRevision(models.Model): mymodel = models.ForeignKey(MyModel, related_name="revisions") published = models.BooleanField(...) # all versionned fields here class Meta: unique_together = (('MyModel', 'published'),) HTH -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.