本文整理汇总了Python中blog.models.Blog.get_latest_blogs方法的典型用法代码示例。如果您正苦于以下问题:Python Blog.get_latest_blogs方法的具体用法?Python Blog.get_latest_blogs怎么用?Python Blog.get_latest_blogs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类blog.models.Blog
的用法示例。
在下文中一共展示了Blog.get_latest_blogs方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: index
# 需要导入模块: from blog.models import Blog [as 别名]
# 或者: from blog.models.Blog import get_latest_blogs [as 别名]
def index(request):
# list of news articles
context = {
'list_blogs': Blog.get_latest_blogs()[:5],
'list_news': PressRelease.get_latest_news()[:4],
'view_index': True,
'active_page': "index",
}
return render(request,
'blog/index.html',
context)
示例2: blog
# 需要导入模块: from blog.models import Blog [as 别名]
# 或者: from blog.models.Blog import get_latest_blogs [as 别名]
def blog(request):
""" Using paginator to view list of blog posts """
# list of all blog entries
blog_list_all = Blog.get_latest_blogs()
paginator = Paginator(blog_list_all, 5) # show 5 blogs per page
page = request.GET.get('page')
try:
blogs = paginator.page(page)
except PageNotAnInteger:
# if page is not an integer, deliver first page
blogs = paginator.page(1)
except EmptyPage:
# if page is out of range, deliver last page of results
blogs = paginator.page(paginator.num_pages)
context = {
'list_blogs': Blog.get_latest_blogs()[:5],
'view_index': False,
'main_list': blogs,
'active_page': "blog",
}
return render(request, 'blog/blog.html',
context)
示例3: blog_detail
# 需要导入模块: from blog.models import Blog [as 别名]
# 或者: from blog.models.Blog import get_latest_blogs [as 别名]
def blog_detail(request, blog_id, slug):
# retrieve blog of interest
article_of_interest = get_object_or_404(Blog, pk=blog_id)
context = {
'current_blog': article_of_interest,
'list_blogs': Blog.get_latest_blogs()[:5],
'view_index': False,
'view_blog_entry': True,
'active_page': "blog",
}
return render(request,
'blog/blog-detailed.html',
context)