我们从Python开源项目中,提取了以下4个代码示例,用于说明如何使用django.views.generic.list.ListView()。
def get_table_pagination(self, table): ''' Returns pagination options: True for standard pagination (default), False for no pagination, and a dictionary for custom pagination. ''' paginate = self.table_pagination if hasattr(self, 'paginate_by') and self.paginate_by is not None: # Since ListView knows the concept paginate_by, we use that if no # other pagination is configured. paginate = paginate or {} paginate['per_page'] = self.paginate_by if paginate is None: return True return paginate
def get_list_view_class(self): class UListView(ListView): def get_queryset(self): queryset = super(UListView, self).get_queryset() queryset = queryset.filter(user=self.request.user) return queryset return UListView
def get_queryset(self): logger.debug("Filter by category: %s", self.current_category) q = super(ListView, self).get_queryset().\ filter(node=self.node, graph_category=self.current_category) if not self.subgraph: q = q.filter(parent=None) if self.graph: logger.debug("Filter by graph: %s", self.graph) q = q.filter(pk=self.graph.pk) q = q.select_related('node').order_by('graph_category', 'name') return self.model.objects.munin_ordered(q)