Ticket #5759: 5759-inline_formset_extra_kwargs.diff
File 5759-inline_formset_extra_kwargs.diff, 1.9 KB (added by , 17 years ago) |
---|
-
django/newforms/models.py
286 286 form.fields[self._pk_field_name] = IntegerField(required=False, widget=HiddenInput) 287 287 super(BaseModelFormSet, self).add_fields(form, index) 288 288 289 def formset_for_model(model, form=BaseForm, form field_callback=lambda f: f.formfield(), formset=BaseModelFormSet, extra=1, orderable=False, deletable=False, fields=None):289 def formset_for_model(model, form=BaseForm, formset=BaseModelFormSet, fields=None, formfield_callback=lambda f: f.formfield(), extra=1, orderable=False, deletable=False): 290 290 form = form_for_model(model, form=form, fields=fields, formfield_callback=formfield_callback) 291 291 FormSet = formset_for_form(form, formset, extra, orderable, deletable) 292 292 FormSet.model = model … … 338 338 raise Exception("%s has more than 1 ForeignKey to %s" % (model, parent_model)) 339 339 return fk 340 340 341 def inline_formset(parent_model, model, f k_name=None, fields=None, extra=3, orderable=False, deletable=True, formfield_callback=lambda f: f.formfield()):341 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()): 342 342 """ 343 343 Returns an ``InlineFormset`` for the given kwargs. 344 344 … … 347 347 """ 348 348 fk = get_foreign_key(parent_model, model, fk_name=fk_name) 349 349 # let the formset handle object deletion by default 350 FormSet = formset_for_model(model, form set=InlineFormset, fields=fields,350 FormSet = formset_for_model(model, form=form, formset=formset, fields=fields, 351 351 formfield_callback=formfield_callback, 352 352 extra=extra, orderable=orderable, 353 353 deletable=deletable)