本文整理汇总了Python中django.views.generic.list.MultipleObjectMixin方法的典型用法代码示例。如果您正苦于以下问题:Python list.MultipleObjectMixin方法的具体用法?Python list.MultipleObjectMixin怎么用?Python list.MultipleObjectMixin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.views.generic.list
的用法示例。
在下文中一共展示了list.MultipleObjectMixin方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_allow_future
# 需要导入模块: from django.views.generic import list [as 别名]
# 或者: from django.views.generic.list import MultipleObjectMixin [as 别名]
def get_allow_future(self):
"""
Returns `True` if the view should be allowed to display objects from
the future.
"""
return self.allow_future
# Note: the following three methods only work in subclasses that also
# inherit SingleObjectMixin or MultipleObjectMixin.
示例2: get_datatable_kwargs
# 需要导入模块: from django.views.generic import list [as 别名]
# 或者: from django.views.generic.list import MultipleObjectMixin [as 别名]
def get_datatable_kwargs(self, **kwargs):
queryset = self.get_queryset()
kwargs.update({
'object_list': queryset,
'view': self,
'model': self.model or queryset.model,
})
# This is, i.e., request, provided by default, but if the view is instantiated outside of the request cycle
# (such as for the purposes of embedding that view's datatable elsewhere), the request may
# not be required, so the user may not have a compelling reason to go through the trouble of
# putting it on self.
if hasattr(self, 'request'):
kwargs['url'] = self.request.path
kwargs['query_config'] = getattr(self.request, self.request.method)
else:
kwargs['query_config'] = {}
settings = ('columns', 'exclude', 'ordering', 'start_offset', 'page_length', 'search',
'search_fields', 'unsortable_columns', 'hidden_columns', 'footer',
'structure_template', 'result_counter_id')
for k in settings:
v = getattr(self, k, None)
if v is not None: # MultipleObjectMixin or others might have default attr as None
kwargs[k] = v
return kwargs
# Runtime per-object hook