[Django] #36605: Support chaining `QuerySet.in_bulk()` after `.values()` or `.values_list()`

6 views
Skip to first unread message

Django

unread,
Sep 11, 2025, 6:01:27 AMSep 11
to django-...@googlegroups.com
#36605: Support chaining `QuerySet.in_bulk()` after `.values()` or `.values_list()`
-------------------------------------+-------------------------------------
Reporter: Adam | Owner: Adam Johnson
Johnson |
Type: New | Status: assigned
feature |
Component: Database | Version: dev
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 1
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Per [https://github.com/django/new-features/issues/74 new-features#74 ],
supporting `values()`/`values_list()` to be chained with `in_bulk()` would
allow fetching limited columns while obeying database parameter limits.
The implementation for #28586 would benefit from it, at least.

#35690 improved the error message for these currently-unsupported cases,
but also had an associated PR trying to add support:
https://github.com/django/django/pull/18497 . We can revive this PR and
finish it off.
--
Ticket URL: <https://code.djangoproject.com/ticket/36605>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Sep 11, 2025, 9:34:04 AMSep 11
to django-...@googlegroups.com
#36605: Support chaining `QuerySet.in_bulk()` after `.values()` or `.values_list()`
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: Adam
| Johnson
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls):

* stage: Unreviewed => Accepted

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

Django

unread,
Sep 18, 2025, 4:54:34 PM (13 days ago) Sep 18
to django-...@googlegroups.com
#36605: Support chaining `QuerySet.in_bulk()` after `.values()` or `.values_list()`
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: Adam
| Johnson
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls):

* needs_better_patch: 0 => 1

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

Django

unread,
Sep 24, 2025, 6:32:18 AM (8 days ago) Sep 24
to django-...@googlegroups.com
#36605: Support chaining `QuerySet.in_bulk()` after `.values()` or `.values_list()`
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: Adam
| Johnson
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Adam Johnson):

* needs_better_patch: 1 => 0

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

Django

unread,
Sep 24, 2025, 9:21:07 AM (8 days ago) Sep 24
to django-...@googlegroups.com
#36605: Support chaining `QuerySet.in_bulk()` after `.values()` or `.values_list()`
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: Adam
| Johnson
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls):

* stage: Accepted => Ready for checkin

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

Django

unread,
Sep 25, 2025, 8:51:54 AM (7 days ago) Sep 25
to django-...@googlegroups.com
#36605: Support chaining `QuerySet.in_bulk()` after `.values()` or `.values_list()`
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: Adam
| Johnson
Type: New feature | Status: closed
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Jacob Walls <jacobtylerwalls@…>):

In [changeset:"46bd92274c57fd6f138c067562696092732cec59" 46bd9227]:
{{{#!CommitTicketReference repository=""
revision="46bd92274c57fd6f138c067562696092732cec59"
Refs #36605 -- Optimized QuerySet.in_bulk() for the empty id_list case.

Now that the setup is a bit more expensive, it makes sense to return
earlier
for the empty case.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/36605#comment:6>

Django

unread,
Sep 25, 2025, 8:51:55 AM (7 days ago) Sep 25
to django-...@googlegroups.com
#36605: Support chaining `QuerySet.in_bulk()` after `.values()` or `.values_list()`
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: Adam
| Johnson
Type: New feature | Status: closed
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls <jacobtylerwalls@…>):

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

Comment:

In [changeset:"1820d35b17f0a95f4ce888971b9ca0c7a3697c83" 1820d35]:
{{{#!CommitTicketReference repository=""
revision="1820d35b17f0a95f4ce888971b9ca0c7a3697c83"
Fixed #36605 -- Added support for QuerySet.in_bulk() after .values() or
.values_list().

co-authored-by: Adam Johnson <m...@adamj.eu>
co-authored-by: Simon Charette <chare...@gmail.com>
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/36605#comment:5>
Reply all
Reply to author
Forward
0 new messages