使用Python Restful API在Parse.com中建立1对多关系

使用Python Restful API在Parse.com中建立1对多关系,python,api,parse-platform,Python,Api,Parse Platform,我正在使用Parse来构建我的数据库 我有两个表格:文章&评论。其中文章有一条或多条评论 我正在使用Parse Resful API[ParsePy][1]添加项目 from parse_rest.datatypes import Object class Article(Object): pass class Comment(Object): pass articleItem = Article(title='Test', author='John Doe') articl

我正在使用Parse来构建我的数据库

我有两个表格:
文章
&
评论
。其中
文章
有一条或多条
评论

我正在使用Parse Resful API
[ParsePy][1]
添加项目

from parse_rest.datatypes import Object

class Article(Object):
    pass
class Comment(Object):
    pass

articleItem = Article(title='Test', author='John Doe')
articleItem.save() # we have to save it before it can be referenced
我不知道如何实现这种1:N的关系,有人能展示一种方法来实现这一点:

from parse_rest.datatypes import Object

class Article(Object):
    pass
class Comment(Object):
    pass

articleItem = Article(title='Test', author='John Doe')
# for example, you get data from json
comments = []
for data in incoming_json['comments']:
    # Don't know why, but this cannot working [Comments(**data).save() for data in incoming_json['comments]]
    comment = Comments(**data)
    comment.save()
    comments.append(comment)
articleItem.comments = comments
articleItem.save() # we have to save it before it can be referenced
如果您收到查询,您将收到:

[<Comments:v6PvbsPbQT>, <Comments:V5JpqPRuS6>, <Comments:HNocXqmUeJ>,]
[,]

这就是全部问题吗?看起来您将要显示一个示例。是的!问题是如何使用Parse.Com实现1对多关系