本文整理汇总了Python中models.Post.convert_string_tags方法的典型用法代码示例。如果您正苦于以下问题:Python Post.convert_string_tags方法的具体用法?Python Post.convert_string_tags怎么用?Python Post.convert_string_tags使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Post
的用法示例。
在下文中一共展示了Post.convert_string_tags方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: new_post
# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import convert_string_tags [as 别名]
def new_post():
form = PostForm()
if form.validate_on_submit():
post = Post(title=form.title.data, category=form.category.data, tags=Post.convert_string_tags(form.tags.data))
try:
post.put()
flash(u"Example %s successfully saved." % post.id, "success")
return redirect(url_for("list_posts"))
except CapabilityDisabledError:
flash(u"App Engine Datastore is currently in read-only mode.", "info")
return redirect(url_for("list_posts"))
return render_template("new_post.html", form=form)
示例2: edit_post
# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import convert_string_tags [as 别名]
def edit_post(post_id):
post = Post.get_by_id(post_id)
form = PostForm(obj=post)
if form.validate_on_submit():
form.tags.data = Post.convert_string_tags(form.tags.data)
form.populate_obj(post)
try:
post.put()
flash(u"Example %s successfully saved." % post.id, "success")
# return redirect(url_for('edit_post.html'))
except CapabilityDisabledError:
flash(u"App Engine Datastore is currently in read-only mode.", "info")
return redirect(url_for("list_posts"))
return render_template("edit_post.html", form=form, post_id=post_id)
示例3: edit_post
# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import convert_string_tags [as 别名]
def edit_post(id):
post = Post.get_by_id(id)
form = PostForm(request.form, post)
if form.validate_on_submit():
form.tags.data = Post.convert_string_tags(form.tags.data)
form.populate_obj(post)
try:
post.save()
flash(u'Post aggiornato.', 'success')
return redirect(url_for('list_posts'))
except CapabilityDisabledError:
flash(u'App Engine Datastore is currently in read-only mode.', 'failure')
return redirect(url_for('list_posts'))
return render_template('edit_post.html', form=form)
示例4: new_post
# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import convert_string_tags [as 别名]
def new_post():
form = PostForm()
if form.validate_on_submit():
post = Post(
title = form.title.data,
text = form.text.data,
text_html = form.text.data,
tags = Post.convert_string_tags(form.tags.data),
#tags = []
)
#post = Post()
#form.populate_obj(post)
try:
post.save()
flash(u'Post salvato.', 'success')
return redirect(url_for('list_posts'))
except CapabilityDisabledError:
flash(u'App Engine Datastore is currently in read-only mode.', 'failure')
return redirect(url_for('list_posts'))
return render_template('new_post.html', form=form)