On 8/23/07, James Tauber <[EMAIL PROTECTED]> wrote: > > Looking at previous discussions, I think what I need is much simpler > than others. > > I just have > > class Friendship(models.Model): > to_user = models.ForeignKey(User, related_name="friends") > from_user = models.ForeignKey(User, related_name="_unused_") > > and want to make sure that when Friendship(A, B) is created, > Friendship(B, A) is done so automatically. And similarly if Friendship > (A, B) is deleted, delete the corresponding reversal. I'm just > wondering the recommended way to do that.
I don't think there really would be a 'recommended' way. I haven't looked at the problem in detail, but I don't think that a custom Manager will do the job, either - at least, not by itself. At some point, you will need to create and destroy instances of Friendship via the RelatedManager; the Manager class can be used to filter and modify the search for related instances, but the creation of new instances will require a modified RelatedManager. A _really_ primitive solution would be to override save() and delete() on the friendship class, and then restrict yourself to creating new relationships via the Friendship class itself, but that's not really a good solution. Yours, Russ Magee %-) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---