从django添加并保存对象到parse.com db [英] Add and save objects to parse.com db from django

查看:142
本文介绍了从django添加并保存对象到parse.com db的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用parse.com作为我的django应用程序的数据库。我已经安装了parse_rest,并试图追踪 http://runnable.com/UrzUjbmPNzlOAAOw/using-parse-com-with-python-for-tutorial-beginner-nosql-parsepy-saas-cloud-and-feedparser

I'm experimenting with parse.com as a db for my django app. I've installed parse_rest and am trying to follow http://runnable.com/UrzUjbmPNzlOAAOw/using-parse-com-with-python-for-tutorial-beginner-nosql-parsepy-saas-cloud-and-feedparser.

我有一个字典列表,每个字典的形式如下:

I have a list of dictionaries, with each dictionary of the form:

all_practices = {'a':value1, 'b':value2 ...}

我想保存到parse.com。我有:

I'd like to save this to parse.com. I have:

from parse_rest.datatypes import Object
    practices = Object()
    for p in all_practices:
        practices = p
        practices.save()

这是给我:

'list' object has no attribute 'save'

我做错了什么?

推荐答案

使用ParsePy。如果您不想为parse.com编写自己的包装(我建议),请先尝试调用注册。然后定义一个继承自

It looks like you are using ParsePy. If you don't want to write your own wrapper for parse.com (which I suggest), try calling "register" first. Then define a python class that inherits from the Object

from parse_rest.connection import register
register(<application_id>, <rest_api_key>)



from parse_rest.datatypes import Object
class Profile(Object):
    pass




# instantiate with parameters
profile = Profile(name='Johnny', age=27)

# Change parameters
profile.name = "John"
profile.save()

这篇关于从django添加并保存对象到parse.com db的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆