Ticket #616 (assigned defect)
No support for custom M2M subclasses that change the schema of auto generated through table.
|Reported by:||gregor@…||Owned by:||andrew|
I'm trying to integrate south support into 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 forked south on bitbucket and 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://firstname.lastname@example.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.