Opened 14 years ago

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

Download all attachments as: .zip

Change History (10)

by dalorin, 14 years ago

Attachment: django-13683.diff added

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

comment:1 by dalorin, 14 years ago

Status: newassigned

comment:2 by Julien Phalip, 13 years ago

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 by Julien Phalip, 13 years ago

Keywords: sprintdec2010 added

comment:4 by Julien Phalip, 13 years ago

Severity: Normal
Type: Cleanup/optimization

comment:5 by Julien Phalip, 13 years ago

UI/UX: set

comment:6 by Aymeric Augustin, 12 years ago

UI/UX: unset

Change UI/UX from NULL to False.

comment:7 by Aymeric Augustin, 12 years ago

Easy pickings: unset

Change Easy pickings from NULL to False.

comment:8 by Aymeric Augustin, 12 years ago

UI/UX: set

Revert accidental batch modification.

comment:9 by Aymeric Augustin, 11 years ago

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