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


Python Item.objects方法代码示例

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


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

示例1: get_favorite

# 需要导入模块: from models import Item [as 别名]
# 或者: from models.Item import objects [as 别名]
def get_favorite(id):
    from models import Favorite, Item
    favorite_items = []
    obj = Favorite.objects(user_id=id)
    if obj:
        favorite = obj.get()
        for article_id in favorite.article_list:
            item = Item.objects(artical_id=article_id).get()
            favorite_items.append(item)
    return dumps(convert_items_to_list(favorite_items))
开发者ID:lichuan0217,项目名称:arsenal-server,代码行数:12,代码来源:__init__.py

示例2: index

# 需要导入模块: from models import Item [as 别名]
# 或者: from models.Item import objects [as 别名]
def index(page_number=1):
    """ Display a paginated home page of items, ordered by posting date.
        Implement this when you understand it fully:
        http://flask.pocoo.org/snippets/44/
    """
    # Clean up the page number. I found out that Python's 'pass-by-object'
    # when writing this simple method and my head's a little... shaken.
    page_number = enforce_integer(page_number)

    # Quick calculations for pagination
    number_of_items = Item.objects().count()
    number_of_pages = int(ceil(number_of_items / float(items_per_page)))
    start = (page_number - 1) * items_per_page
    end = start + items_per_page

    # Use array splicing (docs-recommended over start() and limit())
    # to paginate results
    return render_template("index.html",
                           items=Item.objects[start:end].order_by('-posted'), **locals())
开发者ID:afreeorange,项目名称:log,代码行数:21,代码来源:views.py

示例3: search_by_tags

# 需要导入模块: from models import Item [as 别名]
# 或者: from models.Item import objects [as 别名]
def search_by_tags(tagname=None):
    tag_list = tagname.strip().split("+")
    return render_template("index.html", items=Item.objects(tags__in = tag_list))
开发者ID:afreeorange,项目名称:log,代码行数:5,代码来源:views.py

示例4: search_by_type

# 需要导入模块: from models import Item [as 别名]
# 或者: from models.Item import objects [as 别名]
def search_by_type(post_type=None):
    if post_type in [ short_type for short_type, long_type in post_types]:
        return render_template("index.html", items=Item.objects(post_type__exact = post_type))
    else:
        abort(404)
开发者ID:afreeorange,项目名称:log,代码行数:7,代码来源:views.py

示例5: tearDown

# 需要导入模块: from models import Item [as 别名]
# 或者: from models.Item import objects [as 别名]
 def tearDown(self):
     BorrowPast.objects().delete()
     Item.objects().delete()
     CampusLocation.objects().delete()
     User.objects().delete()
     UserGroup.objects().delete()
开发者ID:badrihippo,项目名称:growlin,代码行数:8,代码来源:tests.py


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