本文整理汇总了Python中blog.models.Blog.getone方法的典型用法代码示例。如果您正苦于以下问题:Python Blog.getone方法的具体用法?Python Blog.getone怎么用?Python Blog.getone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类blog.models.Blog
的用法示例。
在下文中一共展示了Blog.getone方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: settings
# 需要导入模块: from blog.models import Blog [as 别名]
# 或者: from blog.models.Blog import getone [as 别名]
def settings():
blog = Blog.getone()
if blog is None:
blog = {}.fromkeys(Blog.get_fields(), '')
flashx.warning('You have no settings, please eidt and save')
return render_template('settings.html', active_tab='settings', blog=blog)
示例2: update_settings
# 需要导入模块: from blog.models import Blog [as 别名]
# 或者: from blog.models.Blog import getone [as 别名]
def update_settings():
name = request.form['name']
description = request.form['description']
disqus = request.form['disqus']
blog = Blog.getone()
if blog is None: # insert
blog = Blog.create(name=name, description=description, disqus=disqus)
flashx.success('Create settings successfully')
else: # update
blog.name = name
blog.disqus = disqus
blog.description = description
blog.save()
flashx.success('Save settings successfully')
return redirect(url_for('settings'))