本文整理汇总了Python中models.Blog.all方法的典型用法代码示例。如果您正苦于以下问题:Python Blog.all方法的具体用法?Python Blog.all怎么用?Python Blog.all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Blog
的用法示例。
在下文中一共展示了Blog.all方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: index
# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import all [as 别名]
def index(request):
context = base_context()
rpp = record_per_page()
cur_page = 1
try:
cur_page = int(request.REQUEST["jumpPage"].strip())
except:
cur_page = 1
blogs_count = Blog.all().count()
max_page = blogs_count / rpp
temp2 = blogs_count % rpp
if temp2 != 0:
max_page = max_page + 1
if cur_page > max_page or cur_page <= 0:
cur_page = max_page
blogs = Blog.all().order("-date").fetch(0)
else:
blogs = Blog.all().order("-date").fetch(rpp, rpp * (cur_page - 1))
context.cur_page = cur_page
context.max_page = max_page
context.action_mode = "/"
context.range1 = range(1, max_page + 1)
context.up_page = cur_page - 1
context.down_page = cur_page + 1
context.blogs = blogs
template = loader.get_template("blogs/index.html")
return HttpResponse(template.render(context))
示例2: show_by_archive
# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import all [as 别名]
def show_by_archive(request, year, month):
context = base_context()
rpp = record_per_page()
cur_page = 1
try:
cur_page = int(request.REQUEST["jumpPage"].strip())
except:
cur_page = 1
blogs_count = Blog.all().filter("year", int(year)).filter("month", int(month)).count()
max_page = blogs_count / rpp
temp2 = blogs_count % rpp
if temp2 != 0:
max_page = max_page + 1
if cur_page > max_page or cur_page <= 0:
cur_page = max_page
if cur_page == 0 or cur_page > max_page:
cur_page = max_page
blogs = Blog.all().filter("year", int(year)).filter("month", int(month)).order("-date").fetch(0)
else:
blogs = (
Blog.all()
.filter("year", int(year))
.filter("month", int(month))
.order("-date")
.fetch(rpp, rpp * (cur_page - 1))
)
context.cur_page = cur_page
context.max_page = max_page
context.action_mode = "/archive/" + year + "/" + month
context.range1 = range(1, max_page + 1)
context.up_page = cur_page - 1
context.down_page = cur_page + 1
context.blogs = blogs
template = loader.get_template("blogs/index.html")
return HttpResponse(template.render(context))
示例3: base_context
# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import all [as 别名]
def base_context():
context = Context({
'current_user':current_user(),
'admin':admin(),
'login_url':users.create_login_url('/blogs'),
'logout_url':users.create_logout_url('/blogs'),
'recent_comments':Comment.all().order('-date').fetch(5),
'categories':Category.all(),
'blogs_count':Blog.all().count(),
'archives':Archive.all().order('-year').order('-month'),
'friendlyURLs':FriendlyURL.all()
})
configuration=Configuration.all().fetch(1)
if configuration:
context.configuration=configuration[0]
return context
示例4: base_context
# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import all [as 别名]
def base_context():
context = Context(
{
"current_user": current_user(),
"admin": admin(),
"login_url": users.create_login_url("/blogs"),
"logout_url": users.create_logout_url("/blogs"),
"recent_comments": Comment.all().order("-date").fetch(5),
"categories": Category.all(),
"blogs_count": Blog.all().count(),
"archives": Archive.all().order("-year").order("-month"),
"friendlyURLs": FriendlyURL.all(),
}
)
configuration = Configuration.all().fetch(1)
if configuration:
context.configuration = configuration[0]
else:
context.configuration = False
return context
示例5: get
# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import all [as 别名]
def get(self):
blogs = Blog.all()
self.render_template("index.html", {"blogs": blogs})
示例6: show_by_category
# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import all [as 别名]
def show_by_category(request, key):
context = base_context()
blogs = Blog.all().filter('category', Category.get(key)).order('-date')
context.blogs = blogs
template = loader.get_template('blogs/index.html')
return HttpResponse(template.render(context))
示例7: show_by_archive
# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import all [as 别名]
def show_by_archive(request, year, month):
context = base_context()
blogs = Blog.all().filter('year', int(year)).filter('month', int(month)).order('-date')
context.blogs = blogs
template = loader.get_template('blogs/index.html')
return HttpResponse(template.render(context))
示例8: index
# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import all [as 别名]
def index(request):
context = base_context()
blogs = Blog.all().order('-date')
context.blogs = blogs
template = loader.get_template('blogs/index.html')
return HttpResponse(template.render(context))