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


Python Place.name方法代码示例

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


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

示例1: test_good_google_location_and_yelp

# 需要导入模块: from models import Place [as 别名]
# 或者: from models.Place import name [as 别名]
 def test_good_google_location_and_yelp(self):
   place = Place()
   place.name = "Whole Foods"
   place.location = '1240 Yale St, Santa Monica, CA 90404'
   place.save()
   self.assertEqual(place.yelp_id, 'hdQJrF3Fw_KrEaDywC3tyg')
   self.assertEqual(len(Place.objects.all()), 1)
开发者ID:jflinter,项目名称:paleomaps,代码行数:9,代码来源:tests.py

示例2: fetchDetailsFromPlaces

# 需要导入模块: from models import Place [as 别名]
# 或者: from models.Place import name [as 别名]
def fetchDetailsFromPlaces(response):
    places = []
    for i in response["results"]:
        place = Place()
        place.name = i["name"]
        place.lat = str(i["geometry"]["location"]["lat"])
        place.lng = str(i["geometry"]["location"]["lng"])
        place.reward = ""
        pointsToSpend = random.randint(0, 100)
        place.offerPoints = str(pointsToSpend)
        place.offerText = "Get our special offer for " + place.offerPoints + " points"
        places.append(place)
    return places
开发者ID:ebarakos,项目名称:trip-quest,代码行数:15,代码来源:utils.py

示例3: test_simple_place_creation

# 需要导入模块: from models import Place [as 别名]
# 或者: from models.Place import name [as 别名]
    def test_simple_place_creation(self):
        """
        Creates test place
        """
        places = Place.objects.filter(name = "Test Place")
        [place.delete() for place in places]

        place = Place()
        place.name = "Test Place"
        place.capacity = 20
        place.save()

        place = Place.objects.filter(name = "Test Place")
        print place
        self.assertNotEqual(place, None)
开发者ID:RadoRado,项目名称:checkin-at-fmi,代码行数:17,代码来源:tests.py

示例4: test_model_inheritance

# 需要导入模块: from models import Place [as 别名]
# 或者: from models.Place import name [as 别名]
    def test_model_inheritance(self):
        # Regression for #7350, #7202
        # Check that when you create a Parent object with a specific reference
        # to an existent child instance, saving the Parent doesn't duplicate
        # the child. This behaviour is only activated during a raw save - it
        # is mostly relevant to deserialization, but any sort of CORBA style
        # 'narrow()' API would require a similar approach.

        # Create a child-parent-grandparent chain
        place1 = Place(
            name="Guido's House of Pasta",
            address='944 W. Fullerton')
        place1.save_base(raw=True)
        restaurant = Restaurant(
            place_ptr=place1,
            serves_hot_dogs=True,
            serves_pizza=False)
        restaurant.save_base(raw=True)
        italian_restaurant = ItalianRestaurant(
            restaurant_ptr=restaurant,
            serves_gnocchi=True)
        italian_restaurant.save_base(raw=True)

        # Create a child-parent chain with an explicit parent link
        place2 = Place(name='Main St', address='111 Main St')
        place2.save_base(raw=True)
        park = ParkingLot(parent=place2, capacity=100)
        park.save_base(raw=True)

        # Check that no extra parent objects have been created.
        places = list(Place.objects.all())
        self.assertEqual(places, [place1, place2])

        dicts = list(Restaurant.objects.values('name','serves_hot_dogs'))
        self.assertEqual(dicts, [{
            'name': u"Guido's House of Pasta",
            'serves_hot_dogs': True
        }])

        dicts = list(ItalianRestaurant.objects.values(
            'name','serves_hot_dogs','serves_gnocchi'))
        self.assertEqual(dicts, [{
            'name': u"Guido's House of Pasta",
            'serves_gnocchi': True,
            'serves_hot_dogs': True,
        }])

        dicts = list(ParkingLot.objects.values('name','capacity'))
        self.assertEqual(dicts, [{
            'capacity': 100,
            'name': u'Main St',
        }])

        # You can also update objects when using a raw save.
        place1.name = "Guido's All New House of Pasta"
        place1.save_base(raw=True)

        restaurant.serves_hot_dogs = False
        restaurant.save_base(raw=True)

        italian_restaurant.serves_gnocchi = False
        italian_restaurant.save_base(raw=True)

        place2.name='Derelict lot'
        place2.save_base(raw=True)

        park.capacity = 50
        park.save_base(raw=True)

        # No extra parent objects after an update, either.
        places = list(Place.objects.all())
        self.assertEqual(places, [place2, place1])
        self.assertEqual(places[0].name, 'Derelict lot')
        self.assertEqual(places[1].name, "Guido's All New House of Pasta")

        dicts = list(Restaurant.objects.values('name','serves_hot_dogs'))
        self.assertEqual(dicts, [{
            'name': u"Guido's All New House of Pasta",
            'serves_hot_dogs': False,
        }])

        dicts = list(ItalianRestaurant.objects.values(
            'name', 'serves_hot_dogs', 'serves_gnocchi'))
        self.assertEqual(dicts, [{
            'name': u"Guido's All New House of Pasta",
            'serves_gnocchi': False,
            'serves_hot_dogs': False,
        }])

        dicts = list(ParkingLot.objects.values('name','capacity'))
        self.assertEqual(dicts, [{
            'capacity': 50,
            'name': u'Derelict lot',
        }])

        # If you try to raw_save a parent attribute onto a child object,
        # the attribute will be ignored.

        italian_restaurant.name = "Lorenzo's Pasta Hut"
        italian_restaurant.save_base(raw=True)
#.........这里部分代码省略.........
开发者ID:MyaThandarKyaw,项目名称:django,代码行数:103,代码来源:tests.py

示例5: test_bad_google_location

# 需要导入模块: from models import Place [as 别名]
# 或者: from models.Place import name [as 别名]
 def test_bad_google_location(self):
   place = Place()
   place.name = "test place"
   place.location = ''
   place.save()
   self.assertEqual(len(Place.objects.all()), 0)
开发者ID:jflinter,项目名称:paleomaps,代码行数:8,代码来源:tests.py


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