[Django] #22115: Related Querysets from Inlines not getting cached

5 views
Skip to first unread message

Django

unread,
Feb 21, 2014, 4:58:25 PM2/21/14
to django-...@googlegroups.com
#22115: Related Querysets from Inlines not getting cached
-------------------------+-------------------------------------------------
Reporter: | Owner: nobody
john.parton@… | Status: new
Type: Bug | Version: 1.6
Component: | Keywords: admin, inline, queryset, queryset
contrib.admin | caching
Severity: Normal | Has patch: 0
Triage Stage: | UI/UX: 0
Unreviewed |
Easy pickings: 0 |
-------------------------+-------------------------------------------------
Here's an overview of my code:

{{{
# models.py
from django.db import models

class ExampleParent(models.Model):

def __unicode__(self):
return u'Example Parent: %s' % self.id

class ExampleInline(models.Model):
parent = models.ForeignKey('ExampleParent')
child = models.ForeignKey('ExampleChild')

def __unicode__(self):
return u'Example Inline: %s' % self.id

class ExampleChild(models.Model):

def __unicode__(self):
return u'Example Child: %s' % self.id


# admin.py
from django.contrib import admin

from admin_issue.example_problem.models import (ExampleParent,
ExampleInline)

class ExampleInlineInline(admin.TabularInline):
model = ExampleInline

class ExampleParentAdmin(admin.ModelAdmin):
inlines = [
ExampleInlineInline
]

admin.site.register(ExampleParent, ExampleParentAdmin)
}}}

If you go to the admin details for an ExampleParent instance, a query will
be executed to fetch all of ExampleChild for as many ExampleInlines are
associated with that ExampleParent. These are exactly identical queries. I
would expect each queryset to be cached and for the ORM.

I have a few models in production that produces hundreds (sometimes over a
thousand) queries. Most of them are exactly identical queries that could
be cached.

I could probably patch my code to work around this, but it seems like the
expected default behavior would be to cache these.

I can generate a small project with a sqlite db if necessary.

John P.

--
Ticket URL: <https://code.djangoproject.com/ticket/22115>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Mar 20, 2014, 4:51:27 PM3/20/14
to django-...@googlegroups.com
#22115: Related Querysets from Inlines not getting cached
-------------------------------------+-------------------------------------
Reporter: john.parton@… | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 1.6
Severity: Normal | Resolution:
Keywords: admin, inline, | Triage Stage: Accepted
queryset, queryset caching | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by aaugustin):

* needs_better_patch: => 0
* needs_docs: => 0
* needs_tests: => 0
* stage: Unreviewed => Accepted


Comment:

This makes sense. However, it might be prohibitively hard to implement.

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

Django

unread,
Nov 23, 2018, 1:53:28 PM11/23/18
to django-...@googlegroups.com
#22115: Related Querysets from Inlines not getting cached
-------------------------------------+-------------------------------------
Reporter: john.parton@… | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 1.6
Severity: Normal | Resolution:
Keywords: admin, inline, | Triage Stage: Accepted
queryset, queryset caching |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham):

Possible duplicate of #5372.

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

Django

unread,
Nov 23, 2018, 7:26:20 PM11/23/18
to django-...@googlegroups.com
#22115: Related Querysets from Inlines not getting cached
-------------------------------------+-------------------------------------
Reporter: john.parton@… | Owner: nobody
Type: Bug | Status: closed
Component: contrib.admin | Version: 1.6
Severity: Normal | Resolution: duplicate

Keywords: admin, inline, | Triage Stage: Accepted
queryset, queryset caching |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):

* status: new => closed
* resolution: => duplicate


Comment:

I confirm this is a duplicate of #5372.

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

Reply all
Reply to author
Forward
0 new messages