text: Opened 11 years ago
  Last modified 4 years ago
  #5372 new Cleanup/optimization
  Cache inline ForeignKey options
  Description
  Attachments (3)
  Change History (17)
  Changed 11 years ago by
  comment:1 Changed 11 years ago by
  comment:2 Changed 11 years ago by
  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.
  Changed 11 years ago by
  comment:3 Changed 11 years ago by
  comment:4 Changed 11 years ago by
  comment:5 Changed 11 years ago by
  The discussion about this one did not reach a consensus:
  therefore I'm taking its triage stage back.
  comment:6 Changed 11 years ago by
  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.
  Changed 11 years ago by
  fixes the real problem. formsets are declarative like forms. 85% done, but attaching to get feedback.
  comment:7 Changed 8 years ago by
  comment:8 Changed 7 years ago by
  Change UI/UX from NULL to False.
  comment:9 Changed 7 years ago by
  Change Easy pickings from NULL to False.
  comment:10 Changed 4 years ago by
  actually, a
  prefetch_related() call might work just as well.
  comment:11 Changed 4 years ago by
  I did some work on this branch:
  Does it make sense?
  See