本文整理汇总了Python中forms.TaskForm.populate_obj方法的典型用法代码示例。如果您正苦于以下问题:Python TaskForm.populate_obj方法的具体用法?Python TaskForm.populate_obj怎么用?Python TaskForm.populate_obj使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类forms.TaskForm
的用法示例。
在下文中一共展示了TaskForm.populate_obj方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: edit_task
# 需要导入模块: from forms import TaskForm [as 别名]
# 或者: from forms.TaskForm import populate_obj [as 别名]
def edit_task(task_id):
task = Task.query.get(task_id)
if g.user.user_id != task.author_id:
flash('You do not have proper authorization to do this!', 'danger')
return redirect('/task/' + str(task_id))
form = TaskForm(obj=task)
if request.method == 'POST' and form.validate():
form = TaskForm(request.form)
form.populate_obj(task)
task.save()
return redirect(url_for('task', task_id=task.task_id))
return render_template('task_form.html', form=form, edit=True)
示例2: task
# 需要导入模块: from forms import TaskForm [as 别名]
# 或者: from forms.TaskForm import populate_obj [as 别名]
def task(id_project, id_task=None):
project = Project.query.get(id_project)
from forms import TaskForm
if id_task != None:
task = task.query.get(id_task)
action = "Save"
else:
task = Task()
action = "Add"
form = TaskForm(obj=task)
if form.validate_on_submit():
form.populate_obj(task)
db.session.add(task)
db.session.commit()
return redirect('/tasks')
return render_template('project/task/form.html', form=form, action=action, project=project)