[Django] #35392: aprefetch_related_objects cannot be imported from django.db.models

14 views
Skip to first unread message

Django

unread,
Apr 19, 2024, 2:36:08 PMApr 19
to django-...@googlegroups.com
#35392: aprefetch_related_objects cannot be imported from django.db.models
-------------------------------------+-------------------------------------
Reporter: James | Owner: nobody
Ostrander |
Type: | Status: new
Uncategorized |
Component: Database | Version: 5.0
layer (models, ORM) | Keywords: prefetch, async,
Severity: Normal | orm
Triage Stage: | Has patch: 1
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
{{{aprefetch_related_objects}}} cannot be imported from
{{{django.db.models}}} like {{{prefetch_related_objects}}} can. Because
the docs (https://docs.djangoproject.com/en/5.0/ref/models/querysets
/#prefetch-related-objects) say nothing about importing the async version
from a different place, I believe this to be an oversight.

You can work around this by importing from {{{django.db.models.query}}}
but if that's the intended behavior, the documentation should be updated
to reflect that. Let me know and I'll do so happily! Otherwise, see my
attached patch for a fix to the import.
--
Ticket URL: <https://code.djangoproject.com/ticket/35392>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Apr 19, 2024, 2:36:50 PMApr 19
to django-...@googlegroups.com
#35392: aprefetch_related_objects cannot be imported from django.db.models
-------------------------------------+-------------------------------------
Reporter: James Ostrander | Owner: nobody
Type: Uncategorized | Status: new
Component: Database layer | Version: 5.0
(models, ORM) |
Severity: Normal | Resolution:
Keywords: prefetch, async, | Triage Stage:
orm | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by James Ostrander):

https://github.com/django/django/pull/18091
--
Ticket URL: <https://code.djangoproject.com/ticket/35392#comment:1>

Django

unread,
Apr 19, 2024, 4:43:13 PMApr 19
to django-...@googlegroups.com
#35392: aprefetch_related_objects cannot be imported from django.db.models
-------------------------------------+-------------------------------------
Reporter: James Ostrander | Owner: James
| Ostrander
Type: Bug | Status: assigned
Component: Database layer | Version: 5.0
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: prefetch, async, | Triage Stage: Accepted
orm |
Has patch: 1 | Needs documentation: 1
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* needs_docs: 0 => 1
* owner: nobody => James Ostrander
* severity: Normal => Release blocker
* stage: Unreviewed => Accepted
* status: new => assigned
* type: Uncategorized => Bug

Comment:

Good catch. It's a bug in fff14736f1cc594f79ea0e2656b8375d837b7aca. Please
add a release note to the `5.0.5.txt`.
--
Ticket URL: <https://code.djangoproject.com/ticket/35392#comment:2>

Django

unread,
Apr 19, 2024, 9:09:28 PMApr 19
to django-...@googlegroups.com
#35392: aprefetch_related_objects cannot be imported from django.db.models
-------------------------------------+-------------------------------------
Reporter: James Ostrander | Owner: James
| Ostrander
Type: Bug | Status: assigned
Component: Database layer | Version: 5.0
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: prefetch, async, | Triage Stage: Accepted
orm |
Has patch: 1 | Needs documentation: 1
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by James Ostrander):

Replying to [comment:2 Mariusz Felisiak]:
> Please add a release note to the `5.0.5.txt`.
Done!
--
Ticket URL: <https://code.djangoproject.com/ticket/35392#comment:3>

Django

unread,
Apr 20, 2024, 8:36:28 AMApr 20
to django-...@googlegroups.com
#35392: aprefetch_related_objects cannot be imported from django.db.models
-------------------------------------+-------------------------------------
Reporter: James Ostrander | Owner: James
| Ostrander
Type: Bug | Status: assigned
Component: Database layer | Version: 5.0
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: prefetch, async, | Triage Stage: Ready for
orm | checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* needs_docs: 1 => 0
* stage: Accepted => Ready for checkin

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

Django

unread,
Apr 22, 2024, 4:05:16 PMApr 22
to django-...@googlegroups.com
#35392: aprefetch_related_objects cannot be imported from django.db.models
-------------------------------------+-------------------------------------
Reporter: James Ostrander | Owner: James
| Ostrander
Type: Bug | Status: closed
Component: Database layer | Version: 5.0
(models, ORM) |
Severity: Release blocker | Resolution: fixed
Keywords: prefetch, async, | Triage Stage: Ready for
orm | checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by nessita <124304+nessita@…>):

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

Comment:

In [changeset:"36b7024b7fc881b319a2b67876e4f72ba680d6a8" 36b7024]:
{{{#!CommitTicketReference repository=""
revision="36b7024b7fc881b319a2b67876e4f72ba680d6a8"
Fixed #35392, Refs #34331 -- Allowed importing aprefetch_related_objects
from django.db.models.

Thanks James Ostrander for the report and fix, and to Tim Graham and
Mariusz Felisiak for the reviews.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/35392#comment:5>

Django

unread,
Apr 22, 2024, 4:06:44 PMApr 22
to django-...@googlegroups.com
#35392: aprefetch_related_objects cannot be imported from django.db.models
-------------------------------------+-------------------------------------
Reporter: James Ostrander | Owner: James
| Ostrander
Type: Bug | Status: closed
Component: Database layer | Version: 5.0
(models, ORM) |
Severity: Release blocker | Resolution: fixed
Keywords: prefetch, async, | Triage Stage: Ready for
orm | checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Natalia <124304+nessita@…>):

In [changeset:"ea81c9d343a400b537caaafb47d03676c03df246" ea81c9d]:
{{{#!CommitTicketReference repository=""
revision="ea81c9d343a400b537caaafb47d03676c03df246"
[5.0.x] Fixed #35392, Refs #34331 -- Allowed importing
aprefetch_related_objects from django.db.models.

Thanks James Ostrander for the report and fix, and to Tim Graham and
Mariusz Felisiak for the reviews.

Backport of 36b7024b7fc881b319a2b67876e4f72ba680d6a8 from main
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/35392#comment:6>
Reply all
Reply to author
Forward
0 new messages