Matt wrote:
> I know where the problem is, and have a work-around but it isn't all
> that pretty. The problem is here:
>
> class FormWrapper:
> ...
> def __getitem__(self, key):
> for field in self.manipulator.fields:
> if field.field_name == key:
> if hasattr(field, 'requires_data_list') and
> hasattr(self.data, 'getlist'):
> data = self.data.getlist(field.field_name)
> else:
> data = self.data.get(field.field_name, None)
> if data is None:
> data = ''
> return FormFieldWrapper(field, data,
> self.error_dict.get(field.field_name, []))
> raise KeyError
>
> the ForeignKey field, "division" in your example, will be the
> field.field_name, but the real data we want is "division_id".
>
> as a workaround, I've inserted the following just before "if data is
> None":
>
> if data is None:
> data = self.data.get('%s_id' % field.field_name,
> None)
>
> Ugly, but does the right thing. Can someone shed light on why this is
> needed?
>
> Thanks.
>
> - matt
>
This is fixed in the new-admin branch. I've forgotten how this actually
worked in the admin before (as you say, it looks for the wrong member),
but it works for all ForeignKey fields ( in both admin and user views)
in that branch.
Robert