我正在遵循这里的示例:https://github.com/pyeve/eve-demo/blob/master/settings.py
当我转到 localhost:5000/apps 时,我可以看到我的集合中的所有文档,但是当我在 localhost:5000/apps/[email protected] 搜索电子邮件时,它显示“404 未找到”。
我已经确认了正则表达式,并且电子邮件地址位于文档中。谁能看出可能出了什么问题吗?
运行.py
from eve import Eve
if __name__ == '__main__':
app = Eve()
app.run()
设置.py:
RESOURCE_METHODS = ['GET', 'POST', 'DELETE']
ITEM_METHODS = ['GET', 'PATCH', 'PUT', 'DELETE']
MONGO_HOST = 'localhost'
MONGO_PORT = 27017
MONGO_DBNAME = 'test_database'
apps = {
'item_title' : 'app',
'additional_lookup' : {
'url' : 'regex("\b[\w.-]+?@\w+?\.\w+?\b")',
'field' : 'developer_email',
},
'schema': {
'address' : {
'type' : 'string'
},
'developer_email' : {
'type' : 'string',
'minlength' : 1,
'maxlength' : 15,
'required' : True,
'unique' : True,
}
}
DOMAIN = {
'apps' : apps,
}
最佳答案
在您的 settings.py 中,您没有正确进行查找。应该是这样。
apps = {
'item_title' : 'app',
'additional_lookup' : {
'url' : 'apps/regex("\b[\w.-]+?@\w+?\.\w+?\b")',
'field' : 'developer_email',
},
'schema': {
'address' : {
'type' : 'string'
},
'developer_email' : {
'type' : 'string',
'minlength' : 1,
'maxlength' : 15,
'required' : True,
'unique' : True,
}
}
关于python - 无法搜索 eve rest API - 附加查找不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43838785/