Opened 7 years ago

Closed 7 years ago

#5891 closed (duplicate)

formset_for_form should put the form's base_fields on the Formset class

Reported by: brosner Owned by: nobody
Component: Forms Version: newforms-admin
Severity: Keywords: nfa-someday
Cc: Triage Stage: Design decision needed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

When an inline in an InlineModelAdmin contains a field that maps to a ForeignKey and has a ton of options (in my case 5,000+) the add/change pages are extremely slow. I began to trace the problem done and it looks like the root of the problem is each ModelChoiceField has its own instance in memory for each form which results in one query per form in the inline. This gets worse when there is many extra forms. There are really almost two ways to fix this problem and I am proposing to fix the code. The alternative is to use Javascript to add more extra forms so only one query is ran.

It looks like it will be better for the Formset to hold the base_fields and then place it on the BaseForm class before creating it so only one query would run for each form instance. Am I missing something here that would cause problems with this kind of solution?

Change History (3)

comment:1 Changed 7 years ago by brosner

  • Keywords nfa-someday added
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Tagging with nfa-someday as this is functionality that is not critical to the merge of the newforms-admin branch. I am unsure if the current admin has the same issue. Could anyone shed some light on that?

comment:2 Changed 7 years ago by brosner

  • Triage Stage changed from Unreviewed to Design decision needed

comment:3 Changed 7 years ago by brosner

  • Resolution set to duplicate
  • Status changed from new to closed

Ah, I didn't know #5372 existed. Marking as duplicate.

Note: See TracTickets for help on using tickets.
Back to Top