Ticket #3765: patch.2.diff

File patch.2.diff, 1.7 KB (added by dswistowski@…, 8 years ago)
  • django/db/models/manipulators.py

     
    130130                        rel_manager.add(f.rel.to._default_manager.get(pk=n))
    131131                    # TODO: Add to 'fields_changed'
    132132
    133         expanded_data = DotExpandedDict(dict(new_data))
     133        expanded_data = DotExpandedDict(new_data.todict())
    134134        # Save many-to-one objects. Example: Add the Choice objects for a Poll.
    135135        for related in self.opts.get_all_related_objects():
    136136            # Create obj_list, which is a DotExpandedDict such as this:
  • django/utils/datastructures.py

     
    232232                    raise ValueError, "MultiValueDict.update() takes either a MultiValueDict or dictionary"
    233233        for key, value in kwargs.iteritems():
    234234            self.setlistdefault(key, []).append(value)
     235   
     236    from sys import version_info
     237    major, minor = version_info[0], version_info[1]
     238    if major==2 and minor>4:
     239        def todict(self):
     240            return dict(self.lists())
     241    else:
     242        def todict(self):
     243            return dict(self)       
     244    del(version_info, major, minor)
     245    todict.__doc__ =  """Returns MultiValueDict as dictionary
     246                       
     247                        >>>MultiValueDict(a=[1,2,3]).todict()
     248                        {'a': [1,2,3]}
     249                      """
     250   
     251   
    235252
    236253class DotExpandedDict(dict):
    237254    """
Back to Top