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