Well, 2 straight forward questions. I am trying to use json with django. I tried to use shell and do import json No errors here. But when I try to use json_dumps() or just dumps() I am getting
NameError: name 'json_dumps' is not defined
Apparently my json import din't work despite having no error.
Also, a few bonus questions I had during this are:
Your error doesn't have anything to do with your question. This is a simple matter of Python namespacing: the function is json.dumps
not json_dumps
.
However, json
has been a part of the standard library since 2.5. simplejson
is a separate library. Unless you know you need it, you should use json
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.