当前位置: 首页>>代码示例>>Python>>正文


Python AttributeDict.update方法代码示例

本文整理汇总了Python中django_tables2.utils.AttributeDict.update方法的典型用法代码示例。如果您正苦于以下问题:Python AttributeDict.update方法的具体用法?Python AttributeDict.update怎么用?Python AttributeDict.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在django_tables2.utils.AttributeDict的用法示例。


在下文中一共展示了AttributeDict.update方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: render_attrs

# 需要导入模块: from django_tables2.utils import AttributeDict [as 别名]
# 或者: from django_tables2.utils.AttributeDict import update [as 别名]
def render_attrs(attrs, **kwargs):
    ret = AttributeDict(kwargs)

    if attrs is not None:
        ret.update(attrs)

    return ret.as_html()
开发者ID:bradleyayers,项目名称:django-tables2,代码行数:9,代码来源:django_tables2.py

示例2: __init__

# 需要导入模块: from django_tables2.utils import AttributeDict [as 别名]
# 或者: from django_tables2.utils.AttributeDict import update [as 别名]
    def __init__(self, id, source=None, params=(), sortable=None,
                 empty_text=None, attrs=None, template=None, data=None):
        """Initialize the table.

        Options that Table supports that affect the data presented are not
        supported in this subclass.  Extra paramters are:

        :param id: The id of the table in the resulting HTML.  You just need
            to provide something that will be unique in the generated page.
        :param source: The URL to get json data from.
        :param params: A tuple of arguments to pass to the get_queryset()
            method.
        :param data: The data to base the table on, if any.
        """
        if data is not None:
            if source is not None or self.source is not None:
                raise AssertionError(
                    "Do not specify both data and source when building a "
                    "DataTablesTable")
            self.params = params
            data_backed_table = True
        else:
            data_backed_table = False
            data = []
            if source is not None:
                self.source = source
        if template is None:
            template = 'ajax_table.html'
        # Even if this is an ajax backed table, we pass data here and patch
        # the queryset in below because of a bootstrapping issue: we want to
        # sort the initial queryset, and this is much cleaner if the table has
        # has its .columns set up which is only done in Table.__init__...
        super(DataTablesTable, self).__init__(
            data=data, sortable=sortable, empty_text=empty_text, attrs=attrs,
            template=template)
        self._full_length = None
        if not data_backed_table:
            self._compute_queryset(params)
        # We are careful about modifying the attrs here -- if it comes from
        # class Meta:-type options, we don't want to modify the original
        # value!
        if self.attrs:
            attrs = AttributeDict(self.attrs)
        else:
            attrs = AttributeDict()
        attrs.update({
            'id': id,
            # Forcing class to display here is a bit specific really.
            'class': 'display',
        })
        self.attrs = attrs
开发者ID:OSSystems,项目名称:lava-server,代码行数:53,代码来源:tables.py


注:本文中的django_tables2.utils.AttributeDict.update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。