diff options
| author | Russell Keith-Magee <russell@keith-magee.com> | 2009-03-10 11:19:26 +0000 |
|---|---|---|
| committer | Russell Keith-Magee <russell@keith-magee.com> | 2009-03-10 11:19:26 +0000 |
| commit | 3c8568a7dcb38aaa5aceec4f20c3ec3f0217a50d (patch) | |
| tree | da5850b07016cc78087b5769e03d3040721a513d /django/forms/formsets.py | |
| parent | d0fff8ccd4d61a848314ada5b386652606d44f00 (diff) | |
Fixed #10271, #10281 -- Fixed the handling multiple inline models that share a common base class and have the link to the inline parent on the base class. Includes modifications that allow the equivalent handling for GenericFields. Thanks to Idan Gazit, Antti Kaihola (akaihola), and Alex Gaynor for their work on this patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10017 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/forms/formsets.py')
| -rw-r--r-- | django/forms/formsets.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/django/forms/formsets.py b/django/forms/formsets.py index 887f130347..10306c7e6d 100644 --- a/django/forms/formsets.py +++ b/django/forms/formsets.py @@ -32,7 +32,7 @@ class BaseFormSet(StrAndUnicode): def __init__(self, data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=ErrorList): self.is_bound = data is not None or files is not None - self.prefix = prefix or 'form' + self.prefix = prefix or self.get_default_prefix() self.auto_id = auto_id self.data = data self.files = files @@ -62,7 +62,7 @@ class BaseFormSet(StrAndUnicode): initial = {TOTAL_FORM_COUNT: self._total_form_count, INITIAL_FORM_COUNT: self._initial_form_count} self.management_form = ManagementForm(initial=initial, auto_id=self.auto_id, prefix=self.prefix) - + # construct the forms in the formset self._construct_forms() @@ -74,7 +74,7 @@ class BaseFormSet(StrAndUnicode): self.forms = [] for i in xrange(self._total_form_count): self.forms.append(self._construct_form(i)) - + def _construct_form(self, i, **kwargs): """ Instantiates and returns the i-th form instance in a formset. @@ -118,7 +118,7 @@ class BaseFormSet(StrAndUnicode): def _get_deleted_forms(self): """ - Returns a list of forms that have been marked for deletion. Raises an + Returns a list of forms that have been marked for deletion. Raises an AttributeError if deletion is not allowed. """ if not self.is_valid() or not self.can_delete: @@ -176,6 +176,11 @@ class BaseFormSet(StrAndUnicode): return [self.forms[i[0]] for i in self._ordering] ordered_forms = property(_get_ordered_forms) + #@classmethod + def get_default_prefix(cls): + return 'form' + get_default_prefix = classmethod(get_default_prefix) + def non_form_errors(self): """ Returns an ErrorList of errors that aren't associated with a particular |
