Skip to content

Commit

Permalink
newforms-admin: Exposed orderable and deletable arguments in inline_f…
Browse files Browse the repository at this point in the history
…ormset.

git-svn-id: http://code.djangoproject.com/svn/django/branches/newforms-admin@6030 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
freakboy3742 committed Aug 31, 2007
1 parent 7405446 commit 2db132e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions django/newforms/models.py
Expand Up @@ -15,7 +15,8 @@

__all__ = (
'save_instance', 'form_for_model', 'form_for_instance', 'form_for_fields',
'ModelChoiceField', 'ModelMultipleChoiceField', 'inline_formset'
'ModelChoiceField', 'ModelMultipleChoiceField', 'formset_for_model',
'inline_formset'
)

def save_instance(form, instance, fields=None, fail_message='saved', commit=True):
Expand Down Expand Up @@ -304,7 +305,7 @@ def save_new(self, form, commit=True):
new_obj = self.model(**kwargs)
return save_instance(form, new_obj, commit=commit)

def inline_formset(parent_model, model, fk_name=None, fields=None, extra=3, formfield_callback=lambda f: f.formfield()):
def inline_formset(parent_model, model, fk_name=None, fields=None, extra=3, orderable=False, deletable=True, formfield_callback=lambda f: f.formfield()):
"""
Returns an ``InlineFormset`` for the given kwargs.
Expand All @@ -323,7 +324,10 @@ def inline_formset(parent_model, model, fk_name=None, fields=None, extra=3, form
else:
raise Exception("%s has more than 1 ForeignKey to %s" % (model, parent_model))
# let the formset handle object deletion by default
FormSet = formset_for_model(model, formset=InlineFormset, fields=fields, formfield_callback=formfield_callback, extra=extra, deletable=True)
FormSet = formset_for_model(model, formset=InlineFormset, fields=fields,
formfield_callback=formfield_callback,
extra=extra, orderable=orderable,
deletable=deletable)
# HACK: remove the ForeignKey to the parent from every form
# This should be done a line above before we pass 'fields' to formset_for_model
# an 'omit' argument would be very handy here
Expand Down

0 comments on commit 2db132e

Please sign in to comment.