﻿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
6758	Multiple 'self' referencing ManyToManyFields in one model overwrite each other's data	notanumber	nobody	"Defining multiple ManyToManyFields in one model is problematic.  When updating one field, all of the others are updated with the same data.

For example, in the following model:

{{{
from django.db import models

class Job(models.Model):
    
    title = models.CharField(max_length=100)
    reports_to = models.ManyToManyField('self', null=True, blank=True, related_name='reports_to_set')
    supervises = models.ManyToManyField('self', null=True, blank=True, related_name='supervises_set')

    class Admin:
        pass
        
    def __unicode__(self):
        return self.title
}}}

Updating a user's data, ""Bill"", 'reports_to' to read ""John"", also sets 'supervises' to ""John"" as well.  Obviously, in this case at least, this is not the desired behaviour.

Adding symmetrical=False does not correct this issue, but raises another:  When updating ""Bill"" to 'reports_to' ""John"", we end up with both users having ""John"" & ""Bill"" in their 'reports_to' & 'supervises' fields.

Tested this on WindowsXP, using SQLite3 & the built-in 'runserver' command.

The test application & project is attached to this ticket.  The admin user/password is ""test""/""test123"""		closed	Database layer (models, ORM)	dev		invalid	ManyToManyField, self, multiple		Unreviewed	0	0	0	0	0	0
