Opened 5 years ago

Closed 2 years ago

#13683 closed Cleanup/optimization (needsinfo)

Don't instantiate empty inline form when max_num is 0

Reported by: dalorin Owned by: dalorin
Component: contrib.admin Version: 1.2
Severity: Normal Keywords: sprintdec2010
Cc: Triage Stage: Design decision needed
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: no UI/UX: yes

Description

Django 1.2 added dynamic addition of Inline forms in the admin interface. In order to support this functionality, InlineAdminFormSet constructs an extra InlineAdminForm using self.formset.empty_form. However, we have an Inline that displays a fixed set of controls and should never be constructed without the appropriate parameters.

The "Add another" javascript control can be hidden by specifying max_num = 0 on the Inline class. However, this does not prevent InlineAdminFormSet attempting to construct the blank form object. I am attaching a patch that changes this behaviour.

Attachments (1)

django-13683.diff (953 bytes) - added by dalorin 5 years ago.
Changes InlineAdminFormSet to check max_num != 0 before constructing empty form

Download all attachments as: .zip

Change History (10)

Changed 5 years ago by dalorin

Changes InlineAdminFormSet to check max_num != 0 before constructing empty form

comment:1 Changed 5 years ago by dalorin

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Status changed from new to assigned

comment:2 Changed 5 years ago by julien

  • Needs tests set
  • Triage Stage changed from Unreviewed to Design decision needed

This sounds reasonable but it's unclear what problem you're exactly trying to solve. Could you provide a more explicit test case?

comment:3 Changed 5 years ago by julien

  • Keywords sprintdec2010 added

comment:4 Changed 4 years ago by julien

  • Severity set to Normal
  • Type set to Cleanup/optimization

comment:5 Changed 4 years ago by julien

  • UI/UX set

comment:6 Changed 4 years ago by aaugustin

  • UI/UX unset

Change UI/UX from NULL to False.

comment:7 Changed 4 years ago by aaugustin

  • Easy pickings unset

Change Easy pickings from NULL to False.

comment:8 Changed 4 years ago by aaugustin

  • UI/UX set

Revert accidental batch modification.

comment:9 Changed 2 years ago by aaugustin

  • Resolution set to needsinfo
  • Status changed from assigned to closed

I don't understanding the description very well either, and I don't know how to reproduce this problem.

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