Code

Ticket #5759: 5759-inline_formset_extra_kwargs.diff

File 5759-inline_formset_extra_kwargs.diff, 1.9 KB (added by akaihola, 7 years ago)

added the formset= kwarg, changed kwarg order

Line 
1Index: django/newforms/models.py
2===================================================================
3--- django/newforms/models.py   (revision 6522)
4+++ django/newforms/models.py   (working copy)
5@@ -286,7 +286,7 @@
6         form.fields[self._pk_field_name] = IntegerField(required=False, widget=HiddenInput)
7         super(BaseModelFormSet, self).add_fields(form, index)
8 
9-def formset_for_model(model, form=BaseForm, formfield_callback=lambda f: f.formfield(), formset=BaseModelFormSet, extra=1, orderable=False, deletable=False, fields=None):
10+def formset_for_model(model, form=BaseForm, formset=BaseModelFormSet, fields=None, formfield_callback=lambda f: f.formfield(), extra=1, orderable=False, deletable=False):
11     form = form_for_model(model, form=form, fields=fields, formfield_callback=formfield_callback)
12     FormSet = formset_for_form(form, formset, extra, orderable, deletable)
13     FormSet.model = model
14@@ -338,7 +338,7 @@
15             raise Exception("%s has more than 1 ForeignKey to %s" % (model, parent_model))
16     return fk
17 
18-def inline_formset(parent_model, model, fk_name=None, fields=None, extra=3, orderable=False, deletable=True, formfield_callback=lambda f: f.formfield()):
19+def inline_formset(parent_model, model, form=BaseForm, formset=InlineFormset, fk_name=None, fields=None, extra=3, orderable=False, deletable=True, formfield_callback=lambda f: f.formfield()):
20     """
21     Returns an ``InlineFormset`` for the given kwargs.
22 
23@@ -347,7 +347,7 @@
24     """
25     fk = get_foreign_key(parent_model, model, fk_name=fk_name)
26     # let the formset handle object deletion by default
27-    FormSet = formset_for_model(model, formset=InlineFormset, fields=fields,
28+    FormSet = formset_for_model(model, form=form, formset=formset, fields=fields,
29                                 formfield_callback=formfield_callback,
30                                 extra=extra, orderable=orderable,
31                                 deletable=deletable)