當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。