當前位置: 首頁>>代碼示例>>Python>>正文


Python utils.TEMPLATE_PACK屬性代碼示例

本文整理匯總了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 
開發者ID:stormsha,項目名稱:StormOnline,代碼行數:26,代碼來源:detail.py

示例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 
開發者ID:stormsha,項目名稱:StormOnline,代碼行數:24,代碼來源:xversion.py

示例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) 
開發者ID:82Flex,項目名稱:DCRM,代碼行數:18,代碼來源:helper.py

示例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
        ) 
開發者ID:SaturdayNeighborhoodHealthClinic,項目名稱:osler,代碼行數:20,代碼來源:forms.py

示例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 
開發者ID:stormsha,項目名稱:StormOnline,代碼行數:10,代碼來源:edit.py

示例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) 
開發者ID:stormsha,項目名稱:StormOnline,代碼行數:15,代碼來源:layout.py

示例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 
開發者ID:stormsha,項目名稱:StormOnline,代碼行數:11,代碼來源:inline.py


注:本文中的crispy_forms.utils.TEMPLATE_PACK屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。