﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
3684	IndexError in Field.get_manipulator_new_data with related fields	imbaczek@…	Adrian Holovaty	"{{{
Traceback (most recent call last):
File ""/home/imbaczek/usr/django-trunk/django/core/handlers/base.py"" in get_response
  77. response = callback(request, *callback_args, **callback_kwargs)
File ""/home/imbaczek/usr/django-trunk/django/contrib/admin/views/decorators.py"" in _checklogin
  55. return view_func(request, *args, **kwargs)
File ""/home/imbaczek/usr/django-trunk/django/views/decorators/cache.py"" in _wrapped_view_func
  39. response = view_func(request, *args, **kwargs)
File ""/home/imbaczek/usr/django-trunk/django/contrib/admin/views/main.py"" in add_stage
  254. new_object = manipulator.save(new_data)
File ""/home/imbaczek/usr/django-trunk/django/db/models/manipulators.py"" in save
  172. if f.core and not isinstance(f, FileField) and f.get_manipulator_new_data(rel_new_data, rel=True) in (None, ''):
File ""/home/imbaczek/usr/django-trunk/django/db/models/fields/__init__.py"" in get_manipulator_new_data
  288. return new_data.get(self.name, [self.get_default()])[0]

  IndexError at /admin/articles/article/add/
  string index out of range
}}}
The root of the problem seems to be that related field's new_data dict is not a MultiValueDict, but a more-or-less usual dict (probably originating from a DotExpandedDict.) This causes all sorts of b0rkage when editing inline related models. A patch that fixes IndexError when the field in question is blank and makes strings as they were passed and not only first letter, though it's probably not correct. The problem exists on the dev server, haven't tried mod_python or anything else.
{{{
Index: __init__.py
===================================================================
--- __init__.py (wersja 4685)
+++ __init__.py (kopia robocza)
@@ -285,7 +285,7 @@
         field's data.
         """"""
         if rel:
-            return new_data.get(self.name, [self.get_default()])[0]
+            return new_data.get(self.name, [self.get_default()])
         val = new_data.get(self.name, self.get_default())
         if not self.empty_strings_allowed and val == '' and self.null:
             val = None
}}}"		closed	contrib.admin	dev		duplicate			Unreviewed	0	0	0	0	0	0
