Don't instantiate empty inline form when max_num is 0
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 8 years ago.
-
Changes InlineAdminFormSet to check max_num != 0 before constructing empty form
Download all attachments as: .zip
Change History (10)
Needs tests: |
set
|
Triage Stage: |
Unreviewed →
Design decision needed
|
Keywords: |
sprintdec2010 added
|
Severity: |
→ Normal
|
Type: |
→ Cleanup/optimization
|
Resolution: |
→ needsinfo
|
Status: |
assigned →
closed
|
Changes InlineAdminFormSet to check max_num != 0 before constructing empty form