From: Jeremy Kerr Date: Sat, 23 Aug 2008 02:25:43 +0000 (+0800) Subject: Use self.fields[field] rather than self.field when iterating form fields X-Git-Url: https://git.ozlabs.org/?a=commitdiff_plain;h=f1f11ba9e5511d5c0534929ed435baee994ff68b;p=patchwork Use self.fields[field] rather than self.field when iterating form fields This way, we included the delegate field added in the MultiplePatchForm's constructor. Signed-off-by: Jeremy Kerr --- diff --git a/apps/patchwork/forms.py b/apps/patchwork/forms.py index 18c6a5e..7385ced 100644 --- a/apps/patchwork/forms.py +++ b/apps/patchwork/forms.py @@ -171,7 +171,8 @@ class MultiplePatchForm(PatchForm): def __init__(self, project, *args, **kwargs): super(MultiplePatchForm, self).__init__(project = project, *args, **kwargs) - self.fields['delegate'] = OptionalDelegateField(project = project) + self.fields['delegate'] = OptionalDelegateField(project = project, + required = False) def save(self, instance, commit = True): opts = instance.__class__._meta @@ -184,7 +185,7 @@ class MultiplePatchForm(PatchForm): if not f.name in data: continue - field = getattr(self, f.name, None) + field = self.fields.get(f.name, None) if not field: continue