1
0
mirror of https://github.com/django/django.git synced 2025-07-04 09:49:12 +00:00

newforms-admin: Changed _get_add_forms() and _get_change_forms() so they don't redefine the global Form object

git-svn-id: http://code.djangoproject.com/svn/django/branches/newforms-admin@5578 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty 2007-07-01 04:44:39 +00:00
parent 3bdc14818f
commit 836d2e7591

View File

@ -49,14 +49,14 @@ class BaseFormSet(object):
def _get_add_forms(self): def _get_add_forms(self):
"""Return a list of all the add forms in this ``FormSet``.""" """Return a list of all the add forms in this ``FormSet``."""
Form = self.form_class FormClass = self.form_class
if not hasattr(self, '_add_forms'): if not hasattr(self, '_add_forms'):
add_forms = [] add_forms = []
for i in range(self.change_form_count, self.total_forms): for i in range(self.change_form_count, self.total_forms):
kwargs = {'auto_id': self.auto_id, 'prefix': self.add_prefix(i)} kwargs = {'auto_id': self.auto_id, 'prefix': self.add_prefix(i)}
if self.data: if self.data:
kwargs['data'] = self.data kwargs['data'] = self.data
add_form = Form(**kwargs) add_form = FormClass(**kwargs)
self.add_fields(add_form, i) self.add_fields(add_form, i)
add_forms.append(add_form) add_forms.append(add_form)
self._add_forms = add_forms self._add_forms = add_forms
@ -65,7 +65,7 @@ class BaseFormSet(object):
def _get_change_forms(self): def _get_change_forms(self):
"""Return a list of all the change forms in this ``FormSet``.""" """Return a list of all the change forms in this ``FormSet``."""
Form = self.form_class FormClass = self.form_class
if not hasattr(self, '_add_forms'): if not hasattr(self, '_add_forms'):
change_forms = [] change_forms = []
for i in range(0, self.change_form_count): for i in range(0, self.change_form_count):
@ -74,7 +74,7 @@ class BaseFormSet(object):
kwargs['data'] = self.data kwargs['data'] = self.data
if self.initial: if self.initial:
kwargs['initial'] = self.initial[i] kwargs['initial'] = self.initial[i]
change_form = Form(**kwargs) change_form = FormClass(**kwargs)
self.add_fields(change_form, i) self.add_fields(change_form, i)
change_forms.append(change_form) change_forms.append(change_form)
self._change_forms= change_forms self._change_forms= change_forms