Opened 8 years ago
Last modified 8 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 |
Pull Requests: | How to create a pull request | ||
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
According to the ticket's flags, the next step(s) to move this issue forward are:
- To provide a patch by sending a pull request. Claim the ticket when you start working so that someone else doesn't duplicate effort. Before sending a pull request, review your work against the patch review checklist. Check the "Has patch" flag on the ticket after sending a pull request and include a link to the pull request in the ticket comment when making that update. The usual format is:
[https://github.com/django/django/pull/#### PR]
.
Note:
See TracTickets
for help on using tickets.
*-to-one relationships support attaching unsaved objects; it would be nice to do something similar for *-to-many relationships.