当前位置: 首页>>代码示例>>Python>>正文


Python Account.city方法代码示例

本文整理汇总了Python中accounts.models.Account.city方法的典型用法代码示例。如果您正苦于以下问题:Python Account.city方法的具体用法?Python Account.city怎么用?Python Account.city使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在accounts.models.Account的用法示例。


在下文中一共展示了Account.city方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: handle

# 需要导入模块: from accounts.models import Account [as 别名]
# 或者: from accounts.models.Account import city [as 别名]
    def handle(self, *args, **options):
        """
        Get JSON response from server, parse it and save to the database
        """
        #create url with headers and get response from request
        req = urllib2.Request(
            "%s?username=%s&api_key=%s" % 
            (settings.NL_SETTINGS['url'], settings.NL_SETTINGS['username'],
             settings.NL_SETTINGS['api_key'])
            )
        
        req.add_header('Accept','application/json')
        req.add_header('Content-Type','application/json')
        
        opener = urllib2.build_opener()
        f = opener.open(req)
        server_data = simplejson.load(f)
        
        #data from server contents meta information and objects
        for object_data in server_data['objects']:
            referral = Referral()
            referral.name = object_data['tr_referral']['name']
            referral.resource_uri = object_data['tr_referral']['resource_uri']
            referral.save()

            account = Account()
            account.birth_date = object_data['birth_date']
            account.city = object_data['city']
            account.email = object_data['email']
            account.first_name = object_data['first_name']
            account.gender = object_data['gender']
            account.last_name = object_data['last_name']
            account.lead = object_data['lead']
            account.last_name = object_data['last_name']
            account.phone = object_data['phone']
            account.resource_uri = object_data['resource_uri']
            account.street_number = object_data['street_number']
            account.tr_input_method = object_data['tr_input_method']
            account.ip_address = object_data['ip_address']
            account.tr_language = object_data['tr_language']
            account.utm_campaign = object_data['utm_campaign']
            account.utm_medium = object_data['utm_medium']
            account.utm_medium = object_data['utm_source']
            account.utm_medium = object_data['zipcode']
            account.tr_referral = referral
            account.save_from_server()
            
            for mailing_list_data in object_data['mailing_lists']:
                mailing_list = MailingList()
                mailing_list.name = mailing_list_data['name']
                mailing_list.resource_uri = mailing_list_data['resource_uri']
                mailing_list.save()
                account.mailing_lists.add(mailing_list)
            
            account.save_from_server()
开发者ID:vehrlich,项目名称:test,代码行数:57,代码来源:get_server_data.py


注:本文中的accounts.models.Account.city方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。