id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
616	No support for custom M2M subclasses that change the schema of auto generated through table.	gregor@…	andrew	"I'm trying to integrate south support into [http://github.com/gregmuellegger/django-sortedm2m django-sortedm2m]. It's basically a {{{ManyToManyField}}} subclass that overwrites the logic of creating the auto generated through model to add a custom field that is used to change the sort order. However its necessary to trick the M2M field to set {{{SortedM2MThroughModel._meta.auto_create}}} to {{{True}}}. (See [http://github.com/gregmuellegger/django-sortedm2m/blob/master/sortedm2m/fields.py] for the actual implementation.)

But this breaks south. It handles the {{{SortedManyToManyField}}} like any other {{{ManyToManyField}}} and skips the column the field has added.

I browsed around in the south code and spotted that the fields used for the intermediary table of a M2M field are hard coded. What's about using introspection to determine the fields used on the M2M? We could spit out then the fields that are on the through model dynamically.

I've [http://bitbucket.org/gregor_muellegger/south forked south on bitbucket] and [http://bitbucket.org/gregor_muellegger/south/changesets pushed some changes to the repository] that adds the behaviour I need. I've tested with django 1.1.0 and 1.2.3 which works fine with normal M2M fields and also with the custom one in django-sortedm2m.

I will also add a patch from {{{hg outgoing -p https://gregor_muellegger@bitbucket.org/andrewgodwin/south}}}

''__A side note:__'' I haven't found any testcases in south which tests the handling of many to many fields. I would like to provide some tests to better demonstrate what I want to achieve. However I had no starting point.
"	defect	assigned	major	1.0	migrations	mercurial		m2m, actions	
