本文整理汇总了Python中formalchemy.FieldSet.render_fields[child_attr_name]方法的典型用法代码示例。如果您正苦于以下问题:Python FieldSet.render_fields[child_attr_name]方法的具体用法?Python FieldSet.render_fields[child_attr_name]怎么用?Python FieldSet.render_fields[child_attr_name]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类formalchemy.FieldSet
的用法示例。
在下文中一共展示了FieldSet.render_fields[child_attr_name]方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_form
# 需要导入模块: from formalchemy import FieldSet [as 别名]
# 或者: from formalchemy.FieldSet import render_fields[child_attr_name] [as 别名]
def add_form(self, resource, dbsession):
"""
returns an edit form for the model
"""
fs = FieldSet(resource.create_transient_subitem(), session=dbsession)
#
# Make the foreign key fields read-only in the add form
#
# 1. If it's a str, we're inside a subsection filtered by
# our parent
if isinstance(resource.subitems_source, str):
parent_wrapper = resource.parent_model()
parent_instance = parent_wrapper.model
relation_attr = getattr(parent_instance.__class__, resource.subitems_source)
child_attr_name = getattr(relation_attr.property.backref, 'key', None)
if child_attr_name is not None:
fs.render_fields[child_attr_name] = fs.render_fields[child_attr_name].hidden()
return fs.render()