#31433: Model.objects.create() doesn't utilize caching for prefetches defined on
the ObjectManager
-------------------------------------+-------------------------------------
Reporter: Nathan | Owner: nobody
Yan |
Type: Bug | Status: new
Component: Database | Version: 3.0
layer (models, ORM) |
Severity: Normal | Keywords: prefetch cache
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
In this example:
{{{
class Foo(models.Model):
objects = FooManager()
class FooManager(models.Manager):
def get_queryset(self):
return (...).prefetch_related("bars")
fooA = Foo.objects.get(...)
fooA.bars # already prefetched + cached for later
fooB = Foo.objects.create()
fooB.bars # not prefetched
fooB.bars # queries again because not included in prefetch cache
}}}
I would expect fooA and fooB's caches to behave similarly since they're
sourced from the same ObjectManager. If it's not a bug, is there a way to
specify the same `prefetch_related` caching functionality for created
objects?
--
Ticket URL: <https://code.djangoproject.com/ticket/31433>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/056.33cb67f7fae75d2d41ea1dec6445de3f%40djangoproject.com.