本文整理汇总了Python中blog.models.Article.get_by_slug方法的典型用法代码示例。如果您正苦于以下问题:Python Article.get_by_slug方法的具体用法?Python Article.get_by_slug怎么用?Python Article.get_by_slug使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类blog.models.Article
的用法示例。
在下文中一共展示了Article.get_by_slug方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: articles_page
# 需要导入模块: from blog.models import Article [as 别名]
# 或者: from blog.models.Article import get_by_slug [as 别名]
def articles_page(request, curr_work=None):
c = get_common_context(request)
if curr_work:
c['curr_article'] = Article.get_by_slug(curr_work)
return render_to_response('article.html', c, context_instance=RequestContext(request))
else:
c['articles'] = Article.objects.all()
return render_to_response('articles.html', c, context_instance=RequestContext(request))
示例2: blog_more
# 需要导入模块: from blog.models import Article [as 别名]
# 或者: from blog.models.Article import get_by_slug [as 别名]
def blog_more(request, page_name=None):
if page_name:
c = get_common_context(request)
c['a'] = BlogArticle.get_by_slug(page_name)
c['articles'] = BlogArticle.objects.all()
c['base_url'] = 'blog'
c['base_title'] = u'Блог'
return render_to_response('articles_more.html', c, context_instance=RequestContext(request))
else:
return HttpResponseRedirect('/blog/%s/' % BlogArticle.objects.all()[0].slug)