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


Python util.flatatt方法代碼示例

本文整理匯總了Python中django.forms.util.flatatt方法的典型用法代碼示例。如果您正苦於以下問題:Python util.flatatt方法的具體用法?Python util.flatatt怎麽用?Python util.flatatt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在django.forms.util的用法示例。


在下文中一共展示了util.flatatt方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: label_tag

# 需要導入模塊: from django.forms import util [as 別名]
# 或者: from django.forms.util import flatatt [as 別名]
def label_tag(self, contents=None, attrs=None):
        """
        Wraps the given contents in a <label>, if the field has an ID attribute.
        contents should be 'mark_safe'd to avoid HTML escaping. If contents
        aren't given, uses the field's HTML-escaped label.

        If attrs are given, they're used as HTML attributes on the <label> tag.
        """
        contents = contents or self.label
        widget = self.field.widget
        id_ = widget.attrs.get('id') or self.auto_id
        if id_:
            attrs = attrs and flatatt(attrs) or ''
            contents = format_html('<label for="{0}"{1}>{2}</label>',
                                   widget.id_for_label(id_), attrs, contents
                                   )
        else:
            contents = conditional_escape(contents)
        return mark_safe(contents) 
開發者ID:blackye,項目名稱:luscan-devel,代碼行數:21,代碼來源:forms.py

示例2: attributes

# 需要導入模塊: from django.forms import util [as 別名]
# 或者: from django.forms.util import flatatt [as 別名]
def attributes(self):
        """
        Returns a dictionary of initial state data for sorting, sort direction, and visibility.

        The default attributes include ``data-config-sortable``, ``data-config-visible``, and (if
        applicable) ``data-config-sorting`` to hold information about the initial sorting state.
        """
        attributes = {
            'data-config-sortable': 'true' if self.sortable else 'false',
            'data-config-visible': 'true' if self.visible else 'false',
        }

        if self.sort_priority is not None:
            attributes['data-config-sorting'] = ','.join(map(six.text_type, [
                self.sort_priority,
                self.index,
                self.sort_direction,
            ]))

        return flatatt(attributes) 
開發者ID:salopensource,項目名稱:sal,代碼行數:22,代碼來源:columns.py

示例3: render

# 需要導入模塊: from django.forms import util [as 別名]
# 或者: from django.forms.util import flatatt [as 別名]
def render(self, name, value, renderer=None, attrs=None):
        """
        renderer: django2.1 新增加的參數,此處不做應用,賦值None做兼容處理
        """
        if value is None:
            value = ''

        final_attrs = self.build_attrs(self.attrs, attrs, name=name)
        return mark_safe(render_to_string('markdown.html', {
            'final_attrs': flatatt(final_attrs),
            'value': conditional_escape(force_text(value)),
            'id': final_attrs['id'],
            'config': self.config,
        })) 
開發者ID:pylixm,項目名稱:django-mdeditor,代碼行數:16,代碼來源:widgets.py

示例4: render

# 需要導入模塊: from django.forms import util [as 別名]
# 或者: from django.forms.util import flatatt [as 別名]
def render(self, name, value, attrs={}):
        """Render the Quill WYSIWYG."""
        if value is None:
            value = ''
        final_attrs = self.build_attrs(attrs, name=name)
        quill_app = apps.get_app_config('quill')
        quill_config = getattr(quill_app, self.config)

        return mark_safe(render_to_string(quill_config['template'], {
            'final_attrs': flatatt(final_attrs),
            'value': value,
            'id': final_attrs['id'],
            'config': self.config,
        })) 
開發者ID:coremke,項目名稱:django-quill,代碼行數:16,代碼來源:widgets.py

示例5: render

# 需要導入模塊: from django.forms import util [as 別名]
# 或者: from django.forms.util import flatatt [as 別名]
def render(self, name, value, attrs=None):
        if value is None:
            value = ''
        final_attrs = self.build_attrs(attrs, type=self.input_type, name=name)
        if value != '':
            # Only add the 'value' attribute if a value is non-empty.
            final_attrs['value'] = force_text(self._format_value(value))
        return format_html('<input{0} />', flatatt(final_attrs)) 
開發者ID:blackye,項目名稱:luscan-devel,代碼行數:10,代碼來源:widgets.py

示例6: tag

# 需要導入模塊: from django.forms import util [as 別名]
# 或者: from django.forms.util import flatatt [as 別名]
def tag(self):
        if 'id' in self.attrs:
            self.attrs['id'] = '%s_%s' % (self.attrs['id'], self.index)
        final_attrs = dict(self.attrs, type='radio', name=self.name, value=self.choice_value)
        if self.is_checked():
            final_attrs['checked'] = 'checked'
        return format_html('<input{0} />', flatatt(final_attrs)) 
開發者ID:blackye,項目名稱:luscan-devel,代碼行數:9,代碼來源:widgets.py

示例7: render

# 需要導入模塊: from django.forms import util [as 別名]
# 或者: from django.forms.util import flatatt [as 別名]
def render(self, name, values, attrs=None):
        final_attrs = self.build_attrs(attrs, type=self.input_type, name=name)
        output = "<span id='%s'>%s</span>%s" %\
            ("id_%s_label" % name,
             "internal-db://",
             ('<input%s />' % util.flatatt(final_attrs)))
        return mark_safe(output) 
開發者ID:CiscoSystems,項目名稱:avos,代碼行數:9,代碼來源:forms.py


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