本文整理匯總了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