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})
Note:
See TracTickets
for help on using tickets.
"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 theupdate
method ofdict
instances returnsNone
. And that is what happens. This is Python behaviour, and nothing to do with the Django functionmodel_to_dict
.