[Django] #28624: Add attribute to let a ManyToMany field behave like a list instead of a set

18 views
Skip to first unread message

Django

unread,
Sep 21, 2017, 9:02:33 AM9/21/17
to django-...@googlegroups.com
#28624: Add attribute to let a ManyToMany field behave like a list instead of a set
-------------------------------------+-------------------------------------
Reporter: david | Owner: david simmen
simmen |
Type: New | Status: assigned
feature |
Component: Database | Version: master
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
An attribute which surpresses the uniw constraint creation an the
generated join table

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

Django

unread,
Sep 21, 2017, 9:14:34 AM9/21/17
to django-...@googlegroups.com
#28624: Add attribute to let a ManyToMany field behave like a list instead of a set
-------------------------------------+-------------------------------------
Reporter: david simmen | Owner: david
| simmen
Type: New feature | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

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

Comment (by Simon Charette):

Hello David, what's the purpose of disabling this constraint?

Isn't something you can achieve by defining a through model without a
`unique_together` constraint? I'm not convinced this is a scenario common
enough to warrant yet another option to `ManyToManyField`.

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

Django

unread,
Sep 25, 2017, 9:17:49 AM9/25/17
to django-...@googlegroups.com
#28624: Add attribute to let a ManyToMany field behave like a list instead of a set
-------------------------------------+-------------------------------------
Reporter: david simmen | Owner: david
| simmen
Type: New feature | Status: closed

Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

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

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


Comment:

I agree with Simon's assessment.

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

Django

unread,
Oct 11, 2017, 5:06:17 PM10/11/17
to django-...@googlegroups.com
#28624: Add attribute to let a ManyToMany field behave like a list instead of a set
-------------------------------------+-------------------------------------
Reporter: david simmen | Owner: david
| simmen
Type: New feature | Status: new

Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

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

* status: closed => new
* resolution: wontfix =>


Comment:

So I went along and used the through functionality for this and run into
the following issues
- i had to add a model calss with just two foreing keys which clutters up
my code
- I lost all the add create functionality which also makes the code more
complex and less understandable

so from an architectural point ov view it would be way more beautiful to
have a parameter on the field

also I do not understand why it is a set by default since I could not find
a definition for many to many which says it has to be a set, so why use a
more limiting collection?

and last but not least i think there are many usecases where a many to
many is a list for example with order and products where a product can be
many times in the same order, and that is not an out of the world scenario

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

Django

unread,
Oct 12, 2017, 5:39:09 PM10/12/17
to django-...@googlegroups.com
#28624: Add attribute to let a ManyToMany field behave like a list instead of a set
-------------------------------------+-------------------------------------
Reporter: david simmen | Owner: david
| simmen
Type: New feature | Status: closed

Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

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

* status: new => closed
* resolution: => wontfix


Comment:

A list isn't appropriate because the database wouldn't preserve ordering
of many-to-many relations.

Maybe [https://pypi.python.org/pypi/django-sortedm2m django-sortedm2m]
would be appropriate for your use case.

To revisit a "wontfix" decision, see
TicketClosingReasons/DontReopenTickets.

By the way, the `add()`, `create()`, etc. limitation of using a `through`
model will be lifted when #9475 is completed.

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

Reply all
Reply to author
Forward
0 new messages