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


Python Place.to_hash方法代码示例

本文整理汇总了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())
开发者ID:ronachong,项目名称:airbnb_clone,代码行数:29,代码来源:place.py

示例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())
开发者ID:ronachong,项目名称:airbnb_clone,代码行数:41,代码来源:place.py


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