Opened 9 years ago

Closed 8 years ago

#3684 closed (duplicate)

IndexError in Field.get_manipulator_new_data with related fields

Reported by: imbaczek@… Owned by: adrian
Component: contrib.admin Version: master
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


Traceback (most recent call last):
File "/home/imbaczek/usr/django-trunk/django/core/handlers/" in get_response
  77. response = callback(request, *callback_args, **callback_kwargs)
File "/home/imbaczek/usr/django-trunk/django/contrib/admin/views/" in _checklogin
  55. return view_func(request, *args, **kwargs)
File "/home/imbaczek/usr/django-trunk/django/views/decorators/" in _wrapped_view_func
  39. response = view_func(request, *args, **kwargs)
File "/home/imbaczek/usr/django-trunk/django/contrib/admin/views/" in add_stage
  254. new_object =
File "/home/imbaczek/usr/django-trunk/django/db/models/" 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/" in get_manipulator_new_data
  288. return new_data.get(, [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.

--- (wersja 4685)
+++ (kopia robocza)
@@ -285,7 +285,7 @@
         field's data.
         if rel:
-            return new_data.get(, [self.get_default()])[0]
+            return new_data.get(, [self.get_default()])
         val = new_data.get(, self.get_default())
         if not self.empty_strings_allowed and val == '' and self.null:
             val = None

Change History (1)

comment:1 Changed 8 years ago by mtredinnick

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to duplicate
  • Status changed from new to closed

Seems to be agreed that this is a dupe of #3765 and the root cause is being diagnosed over there.

Note: See TracTickets for help on using tickets.
Back to Top