本文整理汇总了Python中app.models.place.Place.to_hash方法的典型用法代码示例。如果您正苦于以下问题:Python Place.to_hash方法的具体用法?Python Place.to_hash怎么用?Python Place.to_hash使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app.models.place.Place
的用法示例。
在下文中一共展示了Place.to_hash方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: places
# 需要导入模块: from app.models.place import Place [as 别名]
# 或者: from app.models.place.Place import to_hash [as 别名]
def places():
"""Handle GET and POST requests to /places route.
Return a list of all places in the database in the case of a GET request.
Create a new place record in the database in the case of a POST request.
"""
# handle GET requests:
# --------------------------------------------------------------------------
if request.method == 'GET':
list = ListStyle.list(Place.select(), request)
return jsonify(list)
# handle POST requests:
# --------------------------------------------------------------------------
elif request.method == 'POST':
record = Place( owner=request.form['owner_id'],
city=request.form['city_id'],
name=request.form['name'],
description=request.form['description'],
number_rooms=request.form['number_rooms'],
number_bathrooms=request.form['number_bathrooms'],
max_guest=request.form['max_guest'],
price_by_night=request.form['price_by_night'],
latitude=request.form['latitude'],
longitude=request.form['longitude'] )
record.save()
return jsonify(record.to_hash())
示例2: city_places
# 需要导入模块: from app.models.place import Place [as 别名]
# 或者: from app.models.place.Place import to_hash [as 别名]
def city_places(state_id, city_id):
"""Handle GET & POST requests to /states/<state_id>/cities/<city_id>/places.
Return a list of all places in the database in given city in the case of a
GET request.
Create a new place record in the given city in the database in the case of
a POST request.
"""
# handle GET requests:
# --------------------------------------------------------------------------
if request.method == 'GET':
try:
list = ListStyle.list(Place.select().where(Place.city == city_id), request)
return jsonify(list)
# return 404 not found record does not exist
except Place.DoesNotExist:
return json_response(
add_status_=False,
status_=404,
code=404,
msg="not found"
)
# handle POST requests:
# --------------------------------------------------------------------------
elif request.method == 'POST':
record = Place( owner=request.form['owner_id'],
city=city_id,
name=request.form['name'],
description=request.form['description'],
number_rooms=request.form['number_rooms'],
number_bathrooms=request.form['number_bathrooms'],
max_guest=request.form['max_guest'],
price_by_night=request.form['price_by_night'],
latitude=request.form['latitude'],
longitude=request.form['longitude'] )
record.save()
return jsonify(record.to_hash())