How to get a MongoDB query in Django, such as a field value of a find ()) result.

def uploadfilefiles(request):
    if request.method == "GET":
        return HttpResponseRedirect("/uploadfilepage/")
    fileinfo = json.loads(request.POST["files"])
    client = pymongo.MongoClient("localhost", 27017)
    db = client.cloudfiledb
    filename = fileinfo["flename"]
    md5 = fileinfo["_id"]
    resu =  db[fileinfo["username"] + "fileinfo"].find({"flename": filename})
    if resu.count() == 0:
        db[fileinfo["username"] + "fileinfo"].insert(fileinfo)
        return HttpResponse(json.dumps({"Uploaded": []}))
    else:
        return HttpResponse(resu)

the returned value of the query is
{upright username: upright mochenails, upright chunkSizeboxes: 10485760, upright flenameplates: upright hello.txtwings, upright flenameplates: 38, uplink adDatewords: 1522581711234L, upright strings: upright colors 1118858670-142391491260126019631449407476", the returned values of the query are
{upright usernames: upright mochenails, upright chunkSizeboxes: 10485760, upright flenameplates: 1522581711234L The above return result is displayed in the response of the developer tool of the front-end browser.

Feb.28,2021

resuprint(resu.username)print(resu['username'])list

through experiments and looking at the documents, it is found that the, find () function returns a value of type cursor, while find_one () returns an array or object, so when you want to access a field of the returned document, according to the query function used, if resu = db.collection.find (), you can access it in the following way:
resu = db [username + "fileinfo"]. Find ()

historyfilelist = []
try:
    for ele in resu:
        global historyfilelist
        historyfilelist.append(ele["filename"])
    return HttpResponse(json.dumps(historyfilelist))

if the find_one () function is used, it can be accessed directly through the dictionary (as obtained by _ id below)
resu = db [fileinfo ['username'] + "fileinfo"] .find_one ({"filename": filename})

if resu is None:
    db[fileinfo['username'] + "fileinfo"].insert(fileinfo)
    return HttpResponse(json.dumps({"Uploaded": []}))
elif resu["_id"] == md5:

the above method is feasible.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1eaa44f-47d88.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1eaa44f-47d88.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?