Opened 17 years ago
Closed 17 years ago
#5891 closed (duplicate)
formset_for_form should put the form's base_fields on the Formset class
Reported by: | Brian Rosner | 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: | no | UI/UX: | no |
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 by , 17 years ago
Keywords: | nfa-someday added |
---|
comment:2 by , 17 years ago
Triage Stage: | Unreviewed → Design decision needed |
---|
comment:3 by , 17 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
Ah, I didn't know #5372 existed. Marking as duplicate.
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?