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


Python Post.select方法代码示例

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


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

示例1: admin_index

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import select [as 别名]
def admin_index():
    post_count = Post.select().count()
    comm_count = Comment.select().count()
    tag_count = Tag.select().count()
    cate_count = Category.select().count()
    author = Author.get(id=1)
    posts = Post.select().paginate(1, 5)
    comments = Comment.select().order_by(('published', 'desc')).paginate(1, 5)
    return template('admin/index.html', posts=posts, comments=comments,
                    post_count=post_count, comm_count=comm_count,
                    tag_count=tag_count, cate_count=cate_count, author=author)
开发者ID:iTriumph,项目名称:MiniAkio,代码行数:13,代码来源:admin.py

示例2: test_subquery

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import select [as 别名]
    def test_subquery(self):
        self.create_data(10)

        query = User.where(User.id._in(Post.select(Post.user_id))).select()
        result = query.execute()
        assert result.count == 10

        query = User.where(id=(Post.select(fn.max(Post.user_id)))).select()
        result = query.execute()
        assert result.count == 1
        assert result.one().id == 10

        query = User.where(
            User.id < Post.select(fn.min(Post.user_id))).select()
        result = query.execute()
        assert result.count == 0
开发者ID:bopo,项目名称:skylark,代码行数:18,代码来源:tests.py

示例3: feed

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import select [as 别名]
def feed(id=None):
    # Get feed number <id>
    try:
        feed = Feed.get(Feed.id == id)
    except Feed.DoesNotExist:
        return jsonify(**FEED_NOT_FOUND)

    # populate Category tree
    (categories, feeds) = loadTree()

    # Get posts in decreasing date order
    posts = Post.select().join(Feed).where(Feed.id == id).order_by(Post.published.desc()).paginate(1, 50)

    # Create human-readable datestamps for posts
    datestamps = loadDates(posts)

    # Select return format on requested content-type?
    if request.json is None:
        # Render feed page template
        return render_template("feed.html", 
                               categories=categories, 
                               feeds=feeds, 
                               feed=feed, 
                               posts=posts,
                               datestamps=datestamps)

    else:
        # Return JSON here for client-side formatting?
        return jsonify(response=[dict(feed=feed, posts=posts)])
开发者ID:KyubiSystems,项目名称:Wisewolf,代码行数:31,代码来源:views.py

示例4: get

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import select [as 别名]
 def get(self, tagname, page=1):
     tags = Tag.select().where(Tag.name == tagname)
     postids = [tag.post for tag in tags]
     pagination = Pagination(Post.select().where(
         Post.id << postids), int(page), per_page=8)
     self.render('archive.html', pagination=pagination,
                 name=tagname, obj_url='/tag/%s' % (tagname), flag='tag')
开发者ID:dengmin,项目名称:logpress-tornado,代码行数:9,代码来源:blog.py

示例5: page_post

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import select [as 别名]
def page_post(num):
    if num < 1:
        abort(404)
    posts = Post.select().paginate(num, 5)
    post_count = posts.count()
    pages = (post_count - 1) / 5 + 1
    return template('index.html', posts=posts, page=num, pages=pages)
开发者ID:iTriumph,项目名称:MiniAkio,代码行数:9,代码来源:blog.py

示例6: test_not_in_select

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import select [as 别名]
 def test_not_in_select(self):
     self.create_data(4)
     query = User.where(
         User.id.not_in(Post.select(Post.user_id))
     ).select()
     results = query.execute()
     assert results.count == 0
开发者ID:zhangjinglei,项目名称:skylark,代码行数:9,代码来源:tests.py

示例7: admin

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import select [as 别名]
def admin():
    username = request.get_cookie('admin', secret='some-secret-key')
    if username:
        posts = Post.select().limit(paginate_by)
        return template('templates/admin.tpl', posts=posts, sp=numer_page())
    else:
        return template('templates/index.tpl')
开发者ID:inghvar,项目名称:snippy,代码行数:9,代码来源:snippy.py

示例8: category

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import select [as 别名]
def category(id=None):
    # Get category #id
    try:
        category = Category.get(Category.id == id)
    except Category.DoesNotExist:
        return jsonify(**CATEGORY_NOT_FOUND)

    # Populate Category tree
    (categories, feeds) = loadTree()

    # Get posts in category in decreasing date order
    posts = Post.select().join(Feed).join(Category).where(Category.id == id).order_by(Post.published.desc()).paginate(1, 50)

    # Create human-readable datestamps for posts
    datestamps = loadDates(posts)

    # Return mode dependent on Content-Type?
    if request.json is None:

        # Render category page template
        return render_template("category.html", 
                               category=category, 
                               categories=categories,
                               feeds=feeds, 
                               posts=posts,
                               datestamps=datestamps)

    else:

        # Return JSON data structure
        return jsonify(response=[dict(categories=categories, feeds=feeds, posts=posts)])
开发者ID:KyubiSystems,项目名称:Wisewolf,代码行数:33,代码来源:views.py

示例9: get

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import select [as 别名]
	def get(self,slug):
		query = Post.select()
		post = get_object_or_404(query,Post.slug==slug)
		for comment in post.comments:
			comment.delete_instance()
		PostIndex.delete().where(PostIndex.post_id ==post.id).execute()
		post.delete_instance()
		return redirect('/admin/')
开发者ID:Michael-Jalloh,项目名称:atom,代码行数:10,代码来源:admin.py

示例10: specific_post

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import select [as 别名]
def specific_post(year, month, slug):
    try:
        last_post = Post.select().where(Post.published==True).where(Post.slug==slug).where(Post.date.year==year).where(Post.date.month==month).get()
        page_title = last_post.title
    except Post.DoesNotExist:
        abort(404, "POST not found.")

    return {'post': last_post, 'page_title': page_title}
开发者ID:rennerocha,项目名称:yabe,代码行数:10,代码来源:yabe.py

示例11: get

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import select [as 别名]
	def get(self,year,month,page=1):
		format = '%%%s-%s%%'%(year,month)
		posts = Post.select().where(Post.created ** format)
		pagination = Pagination(posts,int(page),per_page=8)
		self.render('archive.html',
				year=year,month=month,
				pagination=pagination,flag='archives',
				obj_url='/archives/%s/%s'%(year,month))
开发者ID:940825,项目名称:logpress-tornado,代码行数:10,代码来源:blog.py

示例12: get_categories

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import select [as 别名]
def get_categories():
    categories = []
    category = Post.select()
    for cat in category:
        if cat.category not in categories:
            categories.append(cat.category)

    return categories
开发者ID:Zenext,项目名称:Personal-Blog,代码行数:10,代码来源:app.py

示例13: archives

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import select [as 别名]
def archives():
    months = [x.date for x in Post.select()]
    unique_months = list(set(months))
    return render_template('archives.html', posts=get_posts(),
            recent_posts=get_posts(),
            categories=get_categories(),
            months=unique_months,
            archives=get_archive())
开发者ID:Zenext,项目名称:Personal-Blog,代码行数:10,代码来源:app.py

示例14: get

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import select [as 别名]
	def get(self, page=1):
		search_query = request.args.get('q')
		if search_query:
			posts = Post.search_all(search_query)
			max_page = PostIndex.max_post_page_all(search_query)
		else:
			max_page = Post.max_post_page_all()
			posts = Post.select().order_by(Post.timestamp.desc()).paginate(page, POST_PER_PAGE)
		return render_template('posts/list.html', posts=posts, page=page, max_page = max_page)
开发者ID:Michael-Jalloh,项目名称:atom,代码行数:11,代码来源:views.py

示例15: index

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import select [as 别名]
def index():
    try:
        last_post = Post.select().where(Post.published==True).order_by(Post.date).limit(1).get()
        page_title = last_post.title
    except Post.DoesNotExist:
        last_post = None
        page_title = 'Nothing posted yet.'
        
    return {'post': last_post, 'page_title': page_title}
开发者ID:rennerocha,项目名称:yabe,代码行数:11,代码来源:yabe.py


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