Opened 17 years ago
Last modified 10 years ago
#5372 new Cleanup/optimization
Cache inline ForeignKey options
Reported by: | anonymous | Owned by: | nobody |
---|---|---|---|
Component: | contrib.admin | Version: | newforms-admin |
Severity: | Normal | Keywords: | nfa-someday newforms, admin, inlines |
Cc: | cmawebsite@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | yes |
Needs tests: | yes | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Attachments (3)
Change History (17)
by , 17 years ago
Attachment: | newforms-admin-query-caching.diff added |
---|
comment:1 by , 17 years ago
comment:2 by , 17 years ago
I have these models:
from django.db import models class Category(models.Model): name = models.CharField(max_length=255) class Library(models.Model): name = models.CharField(max_length=255) class Book(models.Model): name = models.CharField(max_length=255) category = models.ForeignKey(Category) library = models.ForeignKey(Library)
And I register them:
class BookInline(admin.TabularInline): model = Book extra = 10 fields = 'name', 'category', class LibraryOptions(admin.ModelAdmin): inlines = BookInline, admin.site.register(Library, LibraryOptions)
I have ten rows for books in library add form. Each row needs its own sql query to get list of categories. I think that the query should be cached.
It is caching in one request, not between requests. New forms and new formsets are created in each request.
by , 17 years ago
Attachment: | caching-of-sql-queries.diff added |
---|
comment:4 by , 17 years ago
Triage Stage: | Unreviewed → Ready for checkin |
---|
comment:5 by , 17 years ago
Needs documentation: | set |
---|---|
Needs tests: | set |
Triage Stage: | Ready for checkin → Design decision needed |
The discussion about this one did not reach a consensus:
http://groups.google.com/group/django-developers/browse_thread/thread/7aaa8a5297e3c4d5
therefore I'm taking its triage stage back.
comment:6 by , 17 years ago
Keywords: | nfa-someday added |
---|---|
Triage Stage: | Design decision needed → Accepted |
This ticket isn't critical to merge of newforms-admin. Tagging with nfa-someday. This functionality can be accomplished by the user, but I personally feel it needs to be in Django.
by , 17 years ago
Attachment: | formset_refactor_3.diff added |
---|
fixes the real problem. formsets are declarative like forms. 85% done, but attaching to get feedback.
comment:7 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → New feature |
comment:10 by , 10 years ago
Summary: | [newforms-admin] - caching of sql query for inlines → Cache inline ForeignKey options |
---|---|
Type: | New feature → Cleanup/optimization |
actually, a prefetch_related()
call might work just as well.
comment:11 by , 10 years ago
I did some work on this branch: https://github.com/martinblech/django/tree/ticket_5372
Does it make sense?
comment:13 by , 10 years ago
As pointed out on Github the prefetch_related()
approach won't work until inline formsets are taught how to deal with it (#18597).
comment:14 by , 10 years ago
Cc: | added |
---|
See http://groups.google.com/group/django-developers/msg/28a8d0efadc1b079