#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.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/049.0a1c8c2103473b73d533eb90e4634d49%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.