﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
25518	Multiple ManyToManyField related_name documentation	Brandon Chinn	nobody	"I came across a bug [http://stackoverflow.com/questions/32957347/django-manytomany-field-add-not-working the other day] about having a model with multiple `ManyToManyFields` to the same `Model`. The bug occurs with the following code:

{{{
# models.py
class MyModel(models.Model):
    foo = models.ManyToManyField('other_app.OtherModel', related_name='+')
    bar = models.ManyToManyField('other_app.OtherModel', related_name='+')

# shell
>>> x = MyModel.objects.create()
>>> y = OtherModel.objects.create()
>>> x.foo.add(y)
>>> x.foo.all() # returns []
}}}

So there's no errors or anything thrown. However, accessing with the through model still works.

{{{
>>> x.foo.through.objects.all() # returns [<MyModel_othermodel object>]
}}}

I eventually found the answer in the [https://docs.djangoproject.com/en/1.6/ref/models/fields/#django.db.models.ManyToManyField.related_name Django documentation for version 1.6] saying that if you have more than one `ManyToManyField` pointing to the same model, you need to set the `related_name` to a '''''unique value''''' ending in `+`. However, this description was removed starting in the 1.7 docs. I think we need to re-add this in because it's a pretty significant specification about the `ManyToManyField` I would never have found, if not for a [http://stackoverflow.com/questions/13918968/multiple-many-to-many-relations-to-the-same-model-in-django 2012 StackOverflow post]."	Cleanup/optimization	closed	Documentation	1.7	Normal	fixed	manytomanyfield multiple		Ready for checkin	0	0	0	0	0	0
