﻿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
6095	Add the ability to manually create M2M intermediary models	Jacob	floguy	"Consider this code:

{{{
class Person(models.Model):
    # ...

class Group(models.Model):
    #...
    
    members = models.ManyToManyField(Item, through=""Membership"")
    
class Membership(models.Model):
    person = models.ForeignKey(Person)
    group = models.ForeignKey(Group)
    date_joined = models.DateTimeField()

##########

>>> from myapp.models import Person
>>> p = Person.objects.get(...)
>>> p.groups.all()
[<some list of groups>]
}}}

This should work.

That is, I should be able to manually provide the model to be used by the M2M intermediary table (which is currently hard-coded). Currently if you leave out the ""through"" bit this is valid Django code, but you won't be able use the convienent M2M methods -- you'd have to do something like {{{[m.group for m in  person.membership_set.all()]}}} instead of {{{person.groups.all()}}}.

This fixes a ''lot'' of complaints about the M2M system (#785 is one of them, but there are many others)."		closed	Database layer (models, ORM)	dev		fixed			Accepted	1	1	0	1	0	0
