﻿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
21763	Misleading Error: 'ManyRelatedManager' object has no attribute 'add'	anonymous	nobody	"'''Synopsis'''
When defining a many-to-many relationship using a 'through' model, the 'add' and 'create' methods are not available, for good reason. However, rather than failing with a helpful exception directing the user to use the through model, the relevant ManyRelatedManager is simply missing its usual methods, raising a misleading AttributeError instead.

'''Expected Behavior'''
IMO, it would be more helpful, and possibly somewhat more Pythonic, to produce a type of exception that directs the user to use the through model. This correctly indicates the source of the problem, and doesn't require much additional monkeying about since the object already has to know of the need to use one as it is now, since it must be instantiated with no add/create methods.

'''Actual Behavior'''
The ManyRelatedManager is created missing two of its usual methods, raising an AttributeError if they are called. This is misleading[1] and can result in several wasted minutes making sure the method name and object is correct, consulting documentation, and so on.

'''Steps to Reproduce'''
1. Create two simple models.
2. Link them with a third model defined as a 'through' relation.
3. Call add or create on one of the ManyRelatedManagers.

Example:
{{{
#!python
# in models.py
from django.db import models

class Person(models.Model):
    pass

class Group(models.Model):
    members = models.ManyToManyField(Person, through='Membership')

class Membership(models.Model):
    person = models.ForeignKey(Person)
    group = models.ForeignKey(Group)
    date_joined = models.DateField(auto_now_add=True)
}}}

{{{
# on shell
>>> from testing.models import *
>>> group = Group.objects.create()
>>> person = Person.objects.create()
>>> group.members.add(person)
Traceback (most recent call last):
  File ""<console>"", line 1, in <module>
AttributeError: 'ManyRelatedManager' object has no attribute 'add'}}}

[1] See, e.g., [this StackOverflow question](http://stackoverflow.com/q/8095813/2588818) and the related top comment/answer."	Cleanup/optimization	new	Database layer (models, ORM)	master	Normal				Accepted	0	0	1	0	1	0
