#3519: IndexError when creating related objects in admin
---------------------------+------------------------------------------------
   Reporter:  dp_wiz       |                Owner:  adrian         
     Status:  reopened     |            Component:  Admin interface
    Version:  SVN          |           Resolution:                 
   Keywords:  edit_inline  |                Stage:  Accepted       
  Has_patch:  1            |           Needs_docs:  0              
Needs_tests:  1            |   Needs_better_patch:  1              
---------------------------+------------------------------------------------
Comment (by anonymous):

 So, line 133 of django/db/models/manipulators.py reads:
 
 {{{        expanded_data = DotExpandedDict(dict(new_data))}}}
 
 This works fine in python 2.4 (not sure why).  But in python 2.5, the
 new_data is converted into a new dictionary by calling __getitem__, which
 for MultiValueDict returns the last value stored in the list rather than
 the list itself.  In python2.4 the lists were preserved by this call.  The
 subsequent code depended on having lists stored at each key value and used
 the [0] index to grab the first item.
 
 I've just changed line 133 to read:
 
 {{{        expanded_data = DotExpandedDict(dict([(k,new_data.getlist(k))
 for k in new_data.keys()]))}}}
 
 which explicitly describes the conversion into a normal dict and therefore
 preserves the lists at each key which allows the subsequent code to work
 in the same way for python 2.5 and python 2.4.
 
 I haven't had time to write unit tests for this yet, and I'm also not
 certain how to write a test for the admin interface.  If someone can
 enlighten me I'd be more than happy to do it.
 
 See patch.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/3519#comment:10>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to