本文整理汇总了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)