我在 mongo db 中保存了一个令牌,例如 .
db.user.findOne({'token':'7fd74c28-8ba1-11e2-9073-e840f23c81a0'}['uuid'])
{
"_id" : ObjectId("5140114fae4cb51773d8c4f8"),
"username" : "jjj51@gmail.com",
"name" : "vivek",
"mobile" : "12345",
"is_active" : false,
"token" : BinData(3,"hLL6kIugEeKif+hA8jyBoA==")
}
当我在 mongo db 命令行界面中执行时,上述查询工作正常。
当我尝试在 Django 视图中运行时相同的查询。
get_user = db.user.findOne({'token':token}['uuid'])
or `get_user = db.user.findOne({'token':'7fd74c28-8ba1-11e2-9073-e840f23c81a0'}['uuid'])`
我收到一个错误
KeyError at /activateaccount/
'uuid'
请帮我弄清楚为什么我会收到这个错误。
我的数据库
db.user.find()
{ "_id" : ObjectId("5140114fae4cb51773d8c4f8"), "username" : "ghgh@gmail.com", "name" : "Rohit", "mobile" : "12345", "is_active" : false, "token" : BinData(3,"hLL6kIugEeKif+hA8jyBoA==") }
{ "_id" : ObjectId("51401194ae4cb51773d8c4f9"), "username" : "ghg@gmail.com", "name" : "rohit", "mobile" : "12345", "is_active" : false, "token" : BinData(3,"rgBIMIugEeKQBuhA8jyBoA==") }
{ "_id" : ObjectId("514012fcae4cb51874ca3e6f"), "username" : "ghgh@gmail.com", "name" : "rahul", "mobile" : "8528256", "is_active" : false, "token" : BinData(3,"f9dMKIuhEeKQc+hA8jyBoA==") }