I want to print the _id part of the results by running a query on the mongo db, but I am getting the "list index out of range" error.
view;
def deleted(request):
q1=('XX')
q2=('XX')
client = MongoClient("XX")
database = client["XX"]
collection = database["XX"]
query = {}
query["Marketplace"] = q1
query["$or"] = [
{
"Tuyx": q2
}
]
cursor = collection.find(query)
print(cursor)
sonuc= loads(dumps(cursor))
id=sonuc[0]["_id"]
print(id)
client.close()
return render(request, 'deletedlisting.html', {'id':id} )
ti want to print _id value as string;