本文整理汇总了Python中models.Record.give_form方法的典型用法代码示例。如果您正苦于以下问题:Python Record.give_form方法的具体用法?Python Record.give_form怎么用?Python Record.give_form使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Record
的用法示例。
在下文中一共展示了Record.give_form方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: instantiate_and_form
# 需要导入模块: from models import Record [as 别名]
# 或者: from models.Record import give_form [as 别名]
def instantiate_and_form(request, instance, obj_id=None):
"""
Abstracts common operations from actions add/<instance>, edit/<instance>.
Instantiates blank model object obj by it's string name (i. e.
instance=book will produce obj=Book()). Instantiates corresponding
WTForm model_form object form. If obj_id provided, tries to populate
obj with database data.
Populates form with request.from data (if any). Than tries to modify
obj with data in form. Returns ready to use obj, form to caller.
"""
obj = Record().give_child(instance)
form = obj.give_form()
obj = obj.get_by_id_or_new(obj_id)
form = form(request.form, obj=obj)
obj.populate_with(form)
return obj, form