本文整理汇总了Python中models.Post.count方法的典型用法代码示例。如果您正苦于以下问题:Python Post.count方法的具体用法?Python Post.count怎么用?Python Post.count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Post
的用法示例。
在下文中一共展示了Post.count方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_delete
# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import count [as 别名]
def test_delete(self):
assert self.models.where(
User.id == Post.user_id).delete().execute() == 8
assert self.models.where(
User.id == Post.user_id).select().execute().count == 0
assert Post.count() == 0
assert User.count() == 0
示例2: adminpostlist
# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import count [as 别名]
def adminpostlist():
perpage = g.config["ADMIN_ITEM_COUNT"]
args = request.args
page = int(args.get("page", 1))
kargs = {}
if "is_original" in args and args["is_original"] == "true":
kargs["is_original"] = True
elif "is_original" in args and args["is_original"] == "false":
kargs["is_original"] = False
if "allow_visit" in args and args["allow_visit"] == "true":
kargs["allow_visit"] = True
elif "allow_visit" in args and args["allow_visit"] == "false":
kargs["allow_visit"] = False
if "allow_comment" in args and args["allow_comment"] == "true":
kargs["allow_comment"] = True
elif "allow_comment" in args and args["allow_comment"] == "false":
kargs["allow_comment"] = False
postlist = Post.get_page(offset=(page-1)*perpage, limit=perpage, **kargs)
pager = gen_pager(page, Post.count(**kargs), perpage, request.url)
return render_template('admin/postlist.html',
postlist=postlist,
admin_url="pagelist",
pager=pager,
parameter=request.query_string)
示例3: test_delete
# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import count [as 别名]
def test_delete(self):
if db_type != 'sqlite': # sqlite dosen't support 'delete xx from xxx'
assert self.models.where(
User.id == Post.user_id).delete().execute() == 8
assert self.models.where(
User.id == Post.user_id).select().execute().count == 0
assert Post.count() == 0
assert User.count() == 0
示例4: test_count
# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import count [as 别名]
def test_count(self):
self.create_data(4)
assert User.count() == 4
assert Post.count() == 4
query = User.select(fn.count(User.id))
result = query.execute()
assert result.count == 1
assert result.tuples()[0][0] == 4
示例5: count_posts
# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import count [as 别名]
def count_posts():
return Post.count()