Opened 7 years ago

Last modified 7 years ago

#27503 new New feature

Provide a way for to-many rels to be used without the db

Reported by: Marc Tamlyn Owned by: nobody
Component: Database layer (models, ORM) Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

ManyToMany or reverse to many relationships should have a reasonable way to interact with them without them touching the database.

It's hard to think about what this would look like, but it could look something like:

>>> user.groups.set(users)
>>> user.groups._cache == users  # Very explicit, unlikely to mesh well with future access code
... True
>>> user.groups.all() == users  # Via prefetch cache. Nicer but could be confusing
... True
>>> user.groups.save()  # explicit commit
>>> user.save_pending_m2m()  # saves all m2ms with a pending update

Change History (1)

comment:1 by Aymeric Augustin, 7 years ago

Triage Stage: UnreviewedAccepted

*-to-one relationships support attaching unsaved objects; it would be nice to do something similar for *-to-many relationships.

Note: See TracTickets for help on using tickets.
Back to Top