当前位置: 首页>>代码示例>>Python>>正文


Python ArticleForm.validate_on_submit方法代码示例

本文整理汇总了Python中forms.ArticleForm.validate_on_submit方法的典型用法代码示例。如果您正苦于以下问题:Python ArticleForm.validate_on_submit方法的具体用法?Python ArticleForm.validate_on_submit怎么用?Python ArticleForm.validate_on_submit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在forms.ArticleForm的用法示例。


在下文中一共展示了ArticleForm.validate_on_submit方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: article_update

# 需要导入模块: from forms import ArticleForm [as 别名]
# 或者: from forms.ArticleForm import validate_on_submit [as 别名]
def article_update(id):
	article = Article.query.get(id)
	form = ArticleForm(request.form, obj=article)
	if request.method == 'POST':
		if form.validate_on_submit():
			form.populate_obj(article)
			db.session.commit()
		
			flash(u'게시글을 수정하였습니다.', 'success')
			return redirect(url_for('article_list'))

	return render_template('article/update.html', form=form, active_tab='article_update')
开发者ID:DongsikHan,项目名称:D.Han_HW,代码行数:14,代码来源:views.py

示例2: newarticle

# 需要导入模块: from forms import ArticleForm [as 别名]
# 或者: from forms.ArticleForm import validate_on_submit [as 别名]
def newarticle():
    form = ArticleForm()
    if request.method == 'POST':
        if form.validate_on_submit():
            title=form.data['title']
    	    body = form.data['body']
	    a=Article(title=title,body=body,timestamp=datetime.datetime.now(),author=g.user)
	    try:
	        db.session.add(a)
	        db.session.commit()
	        flash(u'发帖完成')
	    except Exception, e:
	        flash(u'发帖失败')
            return render_template('newarticle.html', title = 'newarticle',form = form)
开发者ID:webNO5,项目名称:web,代码行数:16,代码来源:views.py

示例3: add_note

# 需要导入模块: from forms import ArticleForm [as 别名]
# 或者: from forms.ArticleForm import validate_on_submit [as 别名]
def add_note():
    """Add a note."""
    form = ArticleForm()
    if request.method == 'POST':
        if form.validate_on_submit():
            # Get the right number - the article ID
            number = 1
            notes = Note.all().order('-number')
            if notes.count() > 0:
                number = notes[0].number + 1

            note = Note(
                number=number,
                title=form.title.data,
                content=form.content.data,
                tags=form.tags.data,
            )
            note.save()
            return redirect(note.get_absolute_url())
    action_url = url_for('add_note')
    return render_template('add_note.html', form=form, action_url=action_url)
开发者ID:caomw,项目名称:xiakelite,代码行数:23,代码来源:views.py

示例4: edit_article

# 需要导入模块: from forms import ArticleForm [as 别名]
# 或者: from forms.ArticleForm import validate_on_submit [as 别名]
def edit_article(number):
    """Add a article."""
    article = get_aritle_by_number(number)
    if article is None:
        return render_template('404.html'), 404

    form = ArticleForm(
        title=article.title,
        content=article.content,
        is_public=article.is_public,
        tags=article.tags,
    )
    if request.method == 'POST':
        if form.validate_on_submit():
            article.title = form.title.data
            article.content = form.content.data
            article.is_public = form.is_public.data
            article.tags = form.tags.data
            article.save()
            return redirect(article.get_absolute_url())
    action_url = url_for('edit_article', number=number)
    return render_template('add_article.html', form=form, action_url=action_url)
开发者ID:caomw,项目名称:xiakelite,代码行数:24,代码来源:views.py

示例5: article_create

# 需要导入模块: from forms import ArticleForm [as 别名]
# 或者: from forms.ArticleForm import validate_on_submit [as 别名]
def article_create():
	form = ArticleForm()

	# if request.method == 'GET':
	# 	return render_template('article/create.html', active_tab='article_create')
	# elif request.method == 'POST':
	if request.method == 'POST':
		if form.validate_on_submit():

			article = Article(
				title=form.title.data,
				author=form.author.data,
				category=form.category.data,
				content=form.content.data
			)

			db.session.add(article)
			db.session.commit()

			flash(u'게시글을 작성하였습니다.', 'success')
			return redirect(url_for('article_list'))

	return render_template('article/create.html', form=form, active_tab='article_create')
开发者ID:DongsikHan,项目名称:D.Han_HW,代码行数:25,代码来源:views.py

示例6: article_create

# 需要导入模块: from forms import ArticleForm [as 别名]
# 或者: from forms.ArticleForm import validate_on_submit [as 别名]
def article_create():
    if g.user_name == None:
        flash(u'로그인 후 이용해주세요.', 'danger')
        return redirect(url_for('log_in'))
    else:
        form = ArticleForm()
        if request.method == 'POST':
            if form.validate_on_submit():

                article = Article(
                    title = form.title.data,
                    author = form.author.data,
                    category = form.category.data,
                    content = form.content.data,
                )

            db.session.add(article)
            db.session.commit()

            flash(u'게시글을 작성하였습니다.', 'success')
            return redirect(url_for('article_list'))

    return render_template('article/create.html', form=form, active_tab='article_create')
开发者ID:DongsikHan,项目名称:D.Han_HW,代码行数:25,代码来源:controllers.py


注:本文中的forms.ArticleForm.validate_on_submit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。