2008/10/2 David Hall <[EMAIL PROTECTED]>:
> Marek Stępniowski wrote:
>> How does django-reversion deal with relationships between Django models?
>>
>> Version-controlling relationships between entities is an Achilles heel
>> of such applications. I have read django-reversion docs on google code
>> wiki, but I couldn't find any information on that matter.
>>
> This is best explained by example.
>
> Let's say you have two models, Foo and Bar, both under version control.
>
>  >>> class Bar(models.Model):
> ...     pass
> ...
>  >>> class Foo(models.Model):
> ...     bar = models.ForeignKey(Bar)
>
> If you save an instance of Foo, then the primary key of the referenced
> Bar is stored in the version.  Thus, rolling back a version of Foo will
> not roll back the version of Bar.
>
> However, Reversion allows you to create revisions that group related
> changes together:
>
>  >>> @create_revision
> ... def save_relations(foo, bar):
> ...    foo.save()
> ...    bar.save()
>
> This will group the two changes together.  They can then be rolled back
> as a single unit.

Thanks for reply. Your approach is simple and it works. I like it! :-)


Cheers,
-- 
Marek Stępniowski
http://stepniowski.com

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to