当前位置: 首页>>代码示例>>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;未经允许,请勿转载。