On Wed, May 20, 2009 at 12:57 PM, Adam Olsen <arol...@gmail.com> wrote: > > I'm trying to make a tagging application. I want to have tags that > have related tags, ie, if they choose the tag 'car', it should also > choose 'automobile'. If they choose 'automobile', it should not > automatically choose 'car'. I'm using something like: > > class Tag(models.Model): > name = models.CharField(max_length=30) > related = models.ManyToManyField('self') > > If I do this: > >>>> car = Tag(name='car') >>>> car.save() >>>> automobile = Tag(name='automobile') >>>> automobile.save() >>>> car.related.add(automobile) >>>> car.related.all() > [<tag: automobile>] >>>> automobile.related.all() > [<tag: car>] > > How do I make it so that if I add a relation of 'automobile' to 'car', > it doesn't automatically add a reverse relation like that?
You're looking for a non-symmetrical m2m relation: http://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.ManyToManyField.symmetrical 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---