我在这里遵循示例:https://github.com/pyeve/eve-demo/blob/master/settings.py
当我转到 localhost:5000/apps 时,我可以看到我收藏中的所有文档,但是当我在 localhost:5000/apps/example@gmail.com 搜索电子邮件时,它显示“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,
}
}
