Opened 4 years ago

Last modified 4 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: master
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


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
>>>  # explicit commit
>>> user.save_pending_m2m()  # saves all m2ms with a pending update

Change History (1)

comment:1 Changed 4 years ago by Aymeric Augustin

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