本文整理汇总了Python中blog.models.Blog.summary方法的典型用法代码示例。如果您正苦于以下问题:Python Blog.summary方法的具体用法?Python Blog.summary怎么用?Python Blog.summary使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类blog.models.Blog
的用法示例。
在下文中一共展示了Blog.summary方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: newPost
# 需要导入模块: from blog.models import Blog [as 别名]
# 或者: from blog.models.Blog import summary [as 别名]
def newPost(self, blogid, username, password, struct, publish):
self.__isUser(username, password)
# print(("blogid:", blogid))
# print(("struct:", struct))
title = struct['title']
content = struct['description']
categorie = struct['categories'][0]
#生成静态HTML文件
id = None
try:
path = r'{0}/templates'.format(os.path.dirname(__file__))
id = len(sum([i[2] for i in os.walk(path)], []))
# print("博客ID:", id)
static(id, content, categorie, title)
blog = Blog()
blog.blog_id = id
blog.title = title
blog.categorie = categorie
blog.content = content
blog.summary = get_summary(content, 150, u'...')
blog.post_time = datetime.datetime.today()
blog.save()
except Exception as e:
error_log.error("生成静态文件失败:{0}".format(e))
return id
示例2: new
# 需要导入模块: from blog.models import Blog [as 别名]
# 或者: from blog.models.Blog import summary [as 别名]
def new(request):
"""
Add a new blog
"""
if request.method == 'POST':
form = BlogForm(request.POST)
if form.is_valid():
data = form.cleaned_data
blog = Blog()
blog.group = data['group']
blog.status = data['status']
blog.title = data['title']
blog.tag = data['tag']
blog.content = data['content']
blog.summary = data['summary']
blog.access_count = 0
blog.comment_count = 0
blog.create_date = datetime.datetime.now()
blog.update_date = datetime.datetime.now()
blog.save()
return HttpResponseRedirect('/adminshow/%s' % blog.id)
else:
form = BlogForm()
return render_to_response('new.html', {'form':form}, context_instance=RequestContext(request, processors=[new_blog, blog_group]))