[Django] #30421: Allow ManyToMany using a intermediary table to be defined as symmetrical

13 views
Skip to first unread message

Django

unread,
Apr 28, 2019, 5:09:40 AM4/28/19
to django-...@googlegroups.com
#30421: Allow ManyToMany using a intermediary table to be defined as symmetrical
-------------------------------------+-------------------------------------
Reporter: Nadege | Owner: Nadege
Type: New | Status: assigned
feature |
Component: Database | Version: 2.2
layer (models, ORM) | Keywords: many2many, through,
Severity: Normal | symmetrical, through
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Thanks to the work made by Collin Anderson in #9475 I think we can remove
the check
"fields.E332 Many-to-many fields with intermediate tables must not be
symmetrical." with a little adjustment.

This change was discussed in the django-dev mailing list
[https://groups.google.com/forum/#!topic/django-developers/BuT0-Uq8pyc].

This would let have

{{{
class Person(models.Model):
name = models.CharField(max_length=20)
friends = models.ManyToManyField('self', through='Friendship')

class Friendship(models.Model):
first = models.ForeignKey(Person, models.CASCADE, related_name="+")
second = models.ForeignKey(Person, models.CASCADE)
friendship_date = models.DateTimeField()
}}}

and just do something like

{{{
joe.friends.add(anna, through_defaults={'friendship_date':
date.datetime(...)})
}}}

where currently we would have to do
{{{
joe.friends.add(anna, through_defaults={'friendship_date':
date.datetime(...)})
anna.friends.add(joe, through_defaults={'friendship_date':
date.datetime(...)})
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/30421>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Apr 28, 2019, 5:16:25 AM4/28/19
to django-...@googlegroups.com
#30421: Allow ManyToMany using a intermediary table to be defined as symmetrical
-------------------------------------+-------------------------------------
Reporter: Nadege | Owner: Nadege
Type: New feature | Status: assigned
Component: Database layer | Version: 2.2
(models, ORM) |
Severity: Normal | Resolution:
Keywords: many2many, through, | Triage Stage:
symmetrical, through | Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Nadege):

* has_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/30421#comment:1>

Django

unread,
Apr 28, 2019, 5:17:39 AM4/28/19
to django-...@googlegroups.com
#30421: Allow ManyToMany using a intermediary table to be defined as symmetrical
-------------------------------------+-------------------------------------
Reporter: Nadege | Owner: Nadege
Type: New feature | Status: assigned
Component: Database layer | Version: 2.2
(models, ORM) |
Severity: Normal | Resolution:
Keywords: many2many, through, | Triage Stage:
symmetrical, through | Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Nadege):

Pull request: https://github.com/django/django/pull/11298

--
Ticket URL: <https://code.djangoproject.com/ticket/30421#comment:2>

Django

unread,
Apr 29, 2019, 2:21:09 AM4/29/19
to django-...@googlegroups.com
#30421: Allow ManyToManyField using a intermediary table to be defined as
symmetrical.

-------------------------------------+-------------------------------------
Reporter: Nadege | Owner: Nadege
Type: New feature | Status: assigned
Component: Database layer | Version: master

(models, ORM) |
Severity: Normal | Resolution:
Keywords: many2many, through, | Triage Stage: Accepted
symmetrical, through |
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* version: 2.2 => master
* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/30421#comment:3>

Django

unread,
Jun 3, 2019, 4:32:42 AM6/3/19
to django-...@googlegroups.com
#30421: Allow ManyToManyField using a intermediary table to be defined as
symmetrical.

-------------------------------------+-------------------------------------
Reporter: Nadege | Owner: Nadege
Type: New feature | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: many2many, through, | Triage Stage: Accepted
symmetrical, through |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* needs_better_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/30421#comment:4>

Django

unread,
Jun 21, 2019, 11:33:01 AM6/21/19
to django-...@googlegroups.com
#30421: Allow ManyToManyField using a intermediary table to be defined as
symmetrical.

-------------------------------------+-------------------------------------
Reporter: Nadege | Owner: Nadege
Type: New feature | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: many2many, through, | Triage Stage: Ready for
symmetrical, through | checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* needs_better_patch: 1 => 0
* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/30421#comment:5>

Django

unread,
Jun 21, 2019, 11:50:10 AM6/21/19
to django-...@googlegroups.com
#30421: Allow ManyToManyField using a intermediary table to be defined as
symmetrical.

-------------------------------------+-------------------------------------
Reporter: Nadege | Owner: Nadege
Type: New feature | Status: closed

Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: fixed

Keywords: many2many, through, | Triage Stage: Ready for
symmetrical, through | checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"87b1ad6e7351464c60e751b483d9dfce3a2d3382" 87b1ad6e]:
{{{
#!CommitTicketReference repository=""
revision="87b1ad6e7351464c60e751b483d9dfce3a2d3382"
Fixed #30421 -- Allowed symmetrical intermediate table for self-
referential ManyToManyField.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/30421#comment:6>

Reply all
Reply to author
Forward
0 new messages