You could probably consider using post_save signals and make things a bit
little more generic.


On Wed, Aug 10, 2011 at 1:38 PM, Mike Dewhirst <mi...@dewhirst.com.au>wrote:

> I want to update a history record whenever a particular record changes.
>
> Is it reasonable to call a method from within the save method of a model to
> go off and do the work?
>
> def updatehistory(recordx):
>    """ if HistoryX doesn't exist, insert it so the RecordX
>    author can add commentary. Also, add to the story with
>    changed values from recordx every time RecordX.save() """
>    pass
>
> class RecordX(models.Model):
>    ... various fields including 'ancestor' ...
>    def save(self, **kwargs):
>        super(RecordX, self).save(**kwargs)
>        updatehistory(self)
>
> class HistoryX(models.Model):
>    relation = models.OneToOneField(RecordX, to_field='ancestor')
>    story = models.TextField()
>
>
> Is there a better way?
>
> Thanks
>
> Mike
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to django-users+unsubscribe@**
> googlegroups.com <django-users%2bunsubscr...@googlegroups.com>.
> For more options, visit this group at http://groups.google.com/**
> group/django-users?hl=en<http://groups.google.com/group/django-users?hl=en>
> .
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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.

Reply via email to