本文整理汇总了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()
示例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