Ticket #5759: 5759-inline_formset_extra_kwargs.diff

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

added the formset= kwarg, changed kwarg order

  • django/newforms/models.py

     
    286286        form.fields[self._pk_field_name] = IntegerField(required=False, widget=HiddenInput)
    287287        super(BaseModelFormSet, self).add_fields(form, index)
    288288
    289 def formset_for_model(model, form=BaseForm, formfield_callback=lambda f: f.formfield(), formset=BaseModelFormSet, extra=1, orderable=False, deletable=False, fields=None):
     289def formset_for_model(model, form=BaseForm, formset=BaseModelFormSet, fields=None, formfield_callback=lambda f: f.formfield(), extra=1, orderable=False, deletable=False):
    290290    form = form_for_model(model, form=form, fields=fields, formfield_callback=formfield_callback)
    291291    FormSet = formset_for_form(form, formset, extra, orderable, deletable)
    292292    FormSet.model = model
     
    338338            raise Exception("%s has more than 1 ForeignKey to %s" % (model, parent_model))
    339339    return fk
    340340
    341 def inline_formset(parent_model, model, fk_name=None, fields=None, extra=3, orderable=False, deletable=True, formfield_callback=lambda f: f.formfield()):
     341def 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()):
    342342    """
    343343    Returns an ``InlineFormset`` for the given kwargs.
    344344
     
    347347    """
    348348    fk = get_foreign_key(parent_model, model, fk_name=fk_name)
    349349    # let the formset handle object deletion by default
    350     FormSet = formset_for_model(model, formset=InlineFormset, fields=fields,
     350    FormSet = formset_for_model(model, form=form, formset=formset, fields=fields,
    351351                                formfield_callback=formfield_callback,
    352352                                extra=extra, orderable=orderable,
    353353                                deletable=deletable)
Back to Top