Opened 8 years ago
Closed 7 years ago
#27970 closed New feature (fixed)
Allow in_bulk() to use other unique fields besides the primary key
Reported by: | Tom Carrick | Owned by: | Tom Carrick |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Currently in_bulk()
has a very limited set of use-cases, especially since a lot of Django users prefer to keep the ID as the PK even when another field could be used. It could be expanded to be more useful if it could be used on fields other than the ID.
For backwards compatibility, it should only work on unique fields.
Proposed syntax: Foo.objects.in_bulk(['1', '2', 'AB123'], field='account_number')
Change History (6)
comment:1 by , 8 years ago
Summary: | Allow in_bulk() to use other fields → Allow in_bulk() to use other unique fields besides the primary key |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 8 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
Going to have a quick stab at this.
comment:4 by , 7 years ago
Needs documentation: | unset |
---|
Forgot to update the ticket, docs are in now, just needs review.
comment:5 by , 7 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
Seems okay at first glance.