Opened 6 years ago

Closed 4 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 6 years ago.
Changes InlineAdminFormSet to check max_num != 0 before constructing empty form

Download all attachments as: .zip

Change History (10)

Changed 6 years ago by dalorin

Attachment: django-13683.diff added

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

comment:1 Changed 6 years ago by dalorin

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Status: newassigned

comment:2 Changed 6 years ago by Julien Phalip

Needs tests: set
Triage Stage: UnreviewedDesign 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 6 years ago by Julien Phalip

Keywords: sprintdec2010 added

comment:4 Changed 5 years ago by Julien Phalip

Severity: Normal
Type: Cleanup/optimization

comment:5 Changed 5 years ago by Julien Phalip

UI/UX: set

comment:6 Changed 5 years ago by Aymeric Augustin

UI/UX: unset

Change UI/UX from NULL to False.

comment:7 Changed 5 years ago by Aymeric Augustin

Easy pickings: unset

Change Easy pickings from NULL to False.

comment:8 Changed 5 years ago by Aymeric Augustin

UI/UX: set

Revert accidental batch modification.

comment:9 Changed 4 years ago by Aymeric Augustin

Resolution: needsinfo
Status: assignedclosed

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