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


Python Person.phone方法代码示例

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


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

示例1: make_person

# 需要导入模块: from person.models import Person [as 别名]
# 或者: from person.models.Person import phone [as 别名]
def make_person(name, building, relation, address=None, city=None, website=None, phone=None):

    # now associate applicant with building:

    # first find/make person
    people = Person.objects.filter(city=city).filter(name=name)
    person = None
    # check if a previous building object in the db exists
    if people.exists():
        person = people[0]
        print "Already had Person: %s" % person.name
    else:
        # if not,
        # CREATE A NEW PERSON OBJECT HERE
        person = Person()

        person.name = name
        if city:
            person.city = city

        if address:
            person.address = address

        if website:
            person.website = website

        if phone:
            person.phone = phone

        person.save()

    # then find/make association:
    bpeople = BuildingPerson.objects.filter(building=building).filter(person=person)
    bperson = None
    # check if a previous building_person object in the db exists
    if bpeople.exists():
        bperson = bpeople[0]
        print "Already had BuildingPerson: %s with: %s" % (bperson.person.name, bperson.building.address)
    else:
        # if not,
        # CREATE A NEW BUILDING PERSON OBJECT HERE
        bperson = BuildingPerson()

        bperson.person = person
        bperson.building = building
        bperson.relation = relation
        bperson.save()

    return (person, bperson)
开发者ID:enerscore,项目名称:rentrocket,代码行数:51,代码来源:helpers.py


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