Code

Ticket #13683: django-13683.diff

File django-13683.diff, 953 bytes (added by dalorin, 4 years ago)

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

Line 
1Index: django/contrib/admin/helpers.py
2===================================================================
3--- django/contrib/admin/helpers.py     (revision 165603)
4+++ django/contrib/admin/helpers.py     (working copy)
5@@ -208,9 +208,10 @@
6             yield InlineAdminForm(self.formset, form, self.fieldsets,
7                 self.opts.prepopulated_fields, None, self.readonly_fields,
8                 model_admin=self.model_admin)
9-        yield InlineAdminForm(self.formset, self.formset.empty_form,
10-            self.fieldsets, self.opts.prepopulated_fields, None,
11-            self.readonly_fields, model_admin=self.model_admin)
12+        if self.formset.max_num != 0:
13+            yield InlineAdminForm(self.formset, self.formset.empty_form,
14+                self.fieldsets, self.opts.prepopulated_fields, None,
15+                self.readonly_fields, model_admin=self.model_admin)
16 
17     def fields(self):
18         fk = getattr(self.formset, "fk", None)