如何找到关联的资源';使用Python EVE';s返回\u媒体\u作为\u URL
我已在我的settings.py中启用了RETURN\u MEDIA\u AS\u URL。我有一个如下所示的模式:如何找到关联的资源';使用Python EVE';s返回\u媒体\u作为\u URL,python,eve,Python,Eve,我已在我的settings.py中启用了RETURN\u MEDIA\u AS\u URL。我有一个如下所示的模式: schema = { 'type': 'dict', 'schema': { 'action': { 'type': 'string', 'default': 'Favorite' }, 'description': { 'type': 'str
schema = {
'type': 'dict',
'schema': {
'action': {
'type': 'string',
'default': 'Favorite'
},
'description': {
'type': 'string',
'default': 'I really liked this.'
},
'hyperlink': {
'type': 'string',
'default': 'http://placehold.it/300x300'
},
'pic': {
'type': 'media'
}
}
}
{
"_updated": "2015-05-06T17:30:32Z",
"description": "I really liked this.",
"hyperlink": "http://placehold.it/300x300",
"pic": {
"upload_date": "2015-05-06T17:30:32Z",
"length": 119861,
"content_type": "image/png",
"file": null,
"name": "shoebot.png"
},
"_links": {
"self": {
"href": "notification/554a4fb8803bd747eb725d4a",
"title": "Notification"
}
},
...
}
生成资源后,响应项负载如下所示:
schema = {
'type': 'dict',
'schema': {
'action': {
'type': 'string',
'default': 'Favorite'
},
'description': {
'type': 'string',
'default': 'I really liked this.'
},
'hyperlink': {
'type': 'string',
'default': 'http://placehold.it/300x300'
},
'pic': {
'type': 'media'
}
}
}
{
"_updated": "2015-05-06T17:30:32Z",
"description": "I really liked this.",
"hyperlink": "http://placehold.it/300x300",
"pic": {
"upload_date": "2015-05-06T17:30:32Z",
"length": 119861,
"content_type": "image/png",
"file": null,
"name": "shoebot.png"
},
"_links": {
"self": {
"href": "notification/554a4fb8803bd747eb725d4a",
"title": "Notification"
}
},
...
}
我的API前缀如下所示:/API/v1/
我似乎不知道GET url会用我的Eve shoebot.png图片回复什么
感谢您给我的建议,让我朝着正确的方向前进:-)返回媒体,因为URL当前位于上,目标是v0.6版本。因此,除非您是从
development
分支运行,否则此功能尚不可用。当然,如果你愿意的话,你可以把它拉下来,自由地进行实验
希望这能有所帮助。答对了!我一直在使用0.5.4,但完全忽略了它针对的是哪个分支。谢谢你,尼古拉。我喜欢这个项目的发展。我发现它非常灵活和强大,几乎可以解决我在RESTAPI周围想到的任何用例:-)。关于你的答案,假设设置媒体端点只在我想自定义而不是使用默认值时才相关。当然是的。我正在更新答案以避免混淆。