本文整理汇总了Python中xadmin.layout.render_field方法的典型用法代码示例。如果您正苦于以下问题:Python layout.render_field方法的具体用法?Python layout.render_field怎么用?Python layout.render_field使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xadmin.layout
的用法示例。
在下文中一共展示了layout.render_field方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: render
# 需要导入模块: from xadmin import layout [as 别名]
# 或者: from xadmin.layout import render_field [as 别名]
def render(self, form, form_style, context, template_pack=TEMPLATE_PACK, **kwargs):
html = ''
instance = form.instance
if not instance.pk:
return super(InlineDiffField, self).render(form, form_style, context)
initial = form.initial
opts = instance._meta
detail = form.detail
for field in self.fields:
f = opts.get_field(field)
f_html = render_field(field, form, form_style, context,
template_pack=template_pack, attrs=self.attrs)
if f.value_from_object(instance) != initial.get(field, None):
current_val = detail.get_field_result(f.name).val
html += ('<div class="diff_field" rel="tooltip"><textarea class="org-data" style="display:none;">%s</textarea>%s</div>'
% (_('Current: %s') % current_val, f_html))
else:
html += f_html
return html
# inline hack plugin
示例2: render
# 需要导入模块: from xadmin import layout [as 别名]
# 或者: from xadmin.layout import render_field [as 别名]
def render(self, form, form_style, context):
html = ''
instance = form.instance
if not instance.pk:
return super(InlineDiffField, self).render(form, form_style, context)
initial = form.initial
opts = instance._meta
detail = form.detail
for field in self.fields:
f = opts.get_field(field)
f_html = render_field(field, form, form_style, context,
template=self.template, attrs=self.attrs)
if f.value_from_object(instance) != initial.get(field, None):
current_val = detail.get_field_result(f.name).val
html += ('<div class="diff_field" rel="tooltip"><textarea class="org-data" style="display:none;">%s</textarea>%s</div>'
% (_('Current: %s') % current_val, f_html))
else:
html += f_html
return html
# inline hack plugin