本文整理汇总了Python中crispy_forms.utils.TEMPLATE_PACK属性的典型用法代码示例。如果您正苦于以下问题:Python utils.TEMPLATE_PACK属性的具体用法?Python utils.TEMPLATE_PACK怎么用?Python utils.TEMPLATE_PACK使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类crispy_forms.utils
的用法示例。
在下文中一共展示了utils.TEMPLATE_PACK属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: render
# 需要导入模块: from crispy_forms import utils [as 别名]
# 或者: from crispy_forms.utils import TEMPLATE_PACK [as 别名]
def render(self, form, form_style, context, template_pack=TEMPLATE_PACK, extra_context=None, **kwargs):
super(ShowField, self).render(form, form_style, context, template_pack, extra_context, **kwargs)
if extra_context is None:
extra_context = {}
if hasattr(self, 'wrapper_class'):
extra_context['wrapper_class'] = self.wrapper_class
if self.attrs:
if 'detail-class' in self.attrs:
extra_context['input_class'] = self.attrs['detail-class']
elif 'class' in self.attrs:
extra_context['input_class'] = self.attrs['class']
html = ''
for field, result in self.results:
extra_context['result'] = result
if field in form.fields:
if form.fields[field].widget != forms.HiddenInput:
extra_context['field'] = form[field]
html += loader.render_to_string(self.template, extra_context)
else:
extra_context['field'] = field
html += loader.render_to_string(self.template, extra_context)
return html
示例2: render
# 需要导入模块: from crispy_forms import utils [as 别名]
# 或者: from crispy_forms.utils import TEMPLATE_PACK [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
示例3: render_layout
# 需要导入模块: from crispy_forms import utils [as 别名]
# 或者: from crispy_forms.utils import TEMPLATE_PACK [as 别名]
def render_layout(self, form, context, template_pack=TEMPLATE_PACK):
"""
Copy any field label to the ``placeholder`` attribute.
Note, this method is called when :attr:`layout` is defined.
"""
# Writing the label values into the field placeholders.
# This is done at rendering time, so the Form.__init__() could update any labels before.
# Django 1.11 no longer lets EmailInput or URLInput inherit from TextInput,
# so checking for `Input` instead while excluding `HiddenInput`.
for field in form.fields.values():
if field.label and \
isinstance(field.widget, (Input, forms.Textarea)) and \
not isinstance(field.widget, forms.HiddenInput):
field.widget.attrs['placeholder'] = u"{0}:".format(field.label)
return super(CompactLabelsCommentFormHelper, self).render_layout(form, context, template_pack=template_pack)
示例4: render
# 需要导入模块: from crispy_forms import utils [as 别名]
# 或者: from crispy_forms.utils import TEMPLATE_PACK [as 别名]
def render(self, form, form_style, context, template_pack=TEMPLATE_PACK,
extra_context=None, **kwargs):
extra_context = (extra_context.copy() if extra_context is not None
else {})
extra_context.update({
'radio_field': form[self.radio_field],
'input_size': self.input_size,
'active': getattr(self, "active", False)
})
if hasattr(self, 'wrapper_class'):
extra_context['wrapper_class'] = self.wrapper_class
template = self.get_template_name(template_pack)
return render_field(
self.field, form, form_style, context,
template=template, attrs=self.attrs,
template_pack=template_pack, extra_context=extra_context, **kwargs
)
示例5: render
# 需要导入模块: from crispy_forms import utils [as 别名]
# 或者: from crispy_forms.utils import TEMPLATE_PACK [as 别名]
def render(self, form, form_style, context, template_pack=TEMPLATE_PACK, **kwargs):
html = ''
for field in self.fields:
result = self.detail.get_field_result(field)
field = {'auto_id': field}
html += loader.render_to_string(
self.template, {'field': field, 'result': result})
return html
示例6: render
# 需要导入模块: from crispy_forms import utils [as 别名]
# 或者: from crispy_forms.utils import TEMPLATE_PACK [as 别名]
def render(self, form, form_style, context, template_pack=TEMPLATE_PACK, **kwargs):
classes = form.fields[self.field].widget.attrs.get('class', '')
extra_context = {
'inputs': self.inputs,
'input_size': self.input_size,
'classes': classes.replace('form-control', '')
}
if hasattr(self, 'wrapper_class'):
extra_context['wrapper_class'] = self.wrapper_class
return render_field(
self.field, form, form_style, context, template=self.template,
attrs=self.attrs, template_pack=template_pack, extra_context=extra_context, **kwargs)
示例7: render
# 需要导入模块: from crispy_forms import utils [as 别名]
# 或者: from crispy_forms.utils import TEMPLATE_PACK [as 别名]
def render(self, form, form_style, context, template_pack=TEMPLATE_PACK, **kwargs):
html = ''
detail = form.detail
for field in self.fields:
if not isinstance(form.fields[field].widget, forms.HiddenInput):
result = detail.get_field_result(field)
html += loader.render_to_string(
self.template, context={'field': form[field], 'result': result})
return html