defuploadfilefiles(request):ifrequest.method=='GET':returnHttpResponseRedirect('/uploadfilepage/')fileinfo=json.loads(request.POST['files'])client=pymongo.MongoClient('localhost',27017)db=client.cloudfiledbfilename=fileinfo["flename"]md5=fileinfo["_id"]resu=db[fileinfo['username']+"fileinfo"].find({"flename":filename})ifresu.count()==0:db[fileinfo['username']+"fileinfo"].insert(fileinfo)returnHttpResponse(json.dumps({"Uploaded":[]}))else:returnHttpResponse(resu)查询的返回值为:{u'username':u'mochen',u'chunkSize':10485760,u'flename':u'hello.txt',u'length':38,u'uploadDate':1522581711234L,u'_id':u'-1118858670-142391418912608919631449407476'},如何在Django中获取某个字段的值,比如在上面的代码else分支中,如何获得resu的username或者其他字段,上面的返回结果是在前端浏览器的开发者工具的response中显示的。
波斯汪
长风秋雁
相关分类