本文整理汇总了Python中models.Blog.id方法的典型用法代码示例。如果您正苦于以下问题:Python Blog.id方法的具体用法?Python Blog.id怎么用?Python Blog.id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Blog
的用法示例。
在下文中一共展示了Blog.id方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_blog
# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import id [as 别名]
def add_blog(request, blog_id=None):
init_session_data(request)
blog = Blog()
if blog_id:
blog.id = blog_id
blog.title = 'New Blog'
blog.content_body = ''
blog.time = datetime.now()
blog.save()
request.session['articles_created'] = request.session['articles_created'].append(blog.id)
request.session['edited_version'] = str(blog.version)
request.session['blog_modified'] = str(blog.id)
request.session['modification'] = 'add'
return HttpResponseRedirect('/editblog/' + str(blog.id))
示例2: edit_blog
# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import id [as 别名]
def edit_blog(request, *, name, summary, content, **kw):
print( check_admin(request))
if(not name or not name.strip()):
raise APIValueError('name','No empty name permited')
if not summary or not summary.strip():
raise APIValueError('summary','empty summary')
if not content or not content.strip():
content=' '
if request.__user__:
blog=Blog(user_id=request.__user__.id, user_name=request.__user__.name, user_image=request.__user__.image, name=name.strip(), summary=summary.strip() , content=content.strip() )
if kw['bid']:
bid=kw['bid']
print('bid='+str(bid) )
blog.id=bid
print(', blog.id='+str(blog.id))
created_at=kw['created_at']
print('created_at='+str(created_at))
blog.created_at=created_at
print(', blog.created_at='+str(created_at))
yield from blog.save()
return blog#################################################################
else:
raise APIError('sign in error','unsign in','please signin')
return None