Opened 14 years ago

Closed 14 years ago

#14197 closed (invalid)

.update() doesn't work on model_to_dict(model_instance)

Reported by: jonathan_livni Owned by: nobody
Component: Uncategorized Version: 1.2
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The following doesn't work:

from django.forms import model_to_dict
dict = model_to_dict(model_instance).update({'a':1})

whereas this does:

from django.forms import model_to_dict
dict = model_to_dict(model_instance)
dict.update({'a':1})


Change History (1)

comment:1 by Luke Plant, 14 years ago

Resolution: invalid
Status: newclosed

"doesn't work" isn't helpful, since we don't know what you expect to happen. I expect the first one to do something different from the second, i.e. the first will end up with dict == None, since the update method of dict instances returns None. And that is what happens. This is Python behaviour, and nothing to do with the Django function model_to_dict.

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