Permalink
Browse files

newforms-admin: Exposed orderable and deletable arguments in inline_f…

…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 2db132ebb75f3b1c64d4415de23bd0781055d534
Showing with 7 additions and 3 deletions.
  1. +7 −3 django/newforms/models.py
View
@@ -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):
@@ -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.
@@ -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

0 comments on commit 2db132e

Please sign in to comment.