当前位置: 首页>>代码示例>>Python>>正文


Python ModelAdmin.changelist_view方法代码示例

本文整理汇总了Python中django.contrib.admin.ModelAdmin.changelist_view方法的典型用法代码示例。如果您正苦于以下问题:Python ModelAdmin.changelist_view方法的具体用法?Python ModelAdmin.changelist_view怎么用?Python ModelAdmin.changelist_view使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在django.contrib.admin.ModelAdmin的用法示例。


在下文中一共展示了ModelAdmin.changelist_view方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: changelist_view

# 需要导入模块: from django.contrib.admin import ModelAdmin [as 别名]
# 或者: from django.contrib.admin.ModelAdmin import changelist_view [as 别名]
 def changelist_view(self, request, extra_context=None):
   if extra_context is None:
     extra_context = {}
   extra_context['menu_option_types'] = MenuOption.MODEL_TYPE_CHOICES
   extra_context['app_label'] = _("GDT Nav")
   extra_context['menu_groups'] = MenuGroup.objects.order_by('name')
   return ModelAdmin.changelist_view(self, request, extra_context)
开发者ID:slinkymanbyday,项目名称:greatlemers-django-tools,代码行数:9,代码来源:admin.py

示例2: changelist_view

# 需要导入模块: from django.contrib.admin import ModelAdmin [as 别名]
# 或者: from django.contrib.admin.ModelAdmin import changelist_view [as 别名]
    def changelist_view(self, request, extra_context=None):
        try:
            action = self.get_actions(request)[request.POST['action']][0]
            action_acts_on_all = action.acts_on_all
        except (KeyError, AttributeError):
            action_acts_on_all = False

        if action_acts_on_all:
            post = request.POST.copy()
            post.setlist(helpers.ACTION_CHECKBOX_NAME,
                         self.model.objects.values_list('pk', flat=True))
            request.POST = post

        return ModelAdmin.changelist_view(self, request, extra_context)
开发者ID:ojos,项目名称:python2.x-library,代码行数:16,代码来源:admin.py

示例3: changelist_view

# 需要导入模块: from django.contrib.admin import ModelAdmin [as 别名]
# 或者: from django.contrib.admin.ModelAdmin import changelist_view [as 别名]
 def changelist_view(self, request, extra_context=None):
     response = ModelAdmin.changelist_view(self, request, extra_context=extra_context)
     queryset = response.context_data['cl'].get_query_set(request)
     queryset_len = queryset.count()
     if queryset_len == 0:
         response.context_data['person'] = None
     else:
         if request.GET.has_key('q'):
             try:
                 response.context_data['person'] = Person.objects.get(name__icontains=request.GET['q'])
             except:
                 response.context_data['person'] = None
             else:
                 min_date = queryset.aggregate(Min('date'))['date__min']
                 max_date = queryset.aggregate(Max('date'))['date__max']
                 start_debt = Debt.objects.filter(person=response.context_data['person'], date__lt=min_date).aggregate(Sum('total'))['total__sum'] or 0.0
                 final_debt = Debt.objects.filter(person=response.context_data['person'], date__lte=max_date).aggregate(Sum('total'))['total__sum'] or 0.0
                 response.context_data['start_debt'] = start_debt
                 response.context_data['final_debt'] = final_debt
                 response.context_data['period_debt'] = final_debt - start_debt
     return response
开发者ID:keeran6,项目名称:check-logist,代码行数:23,代码来源:admin.py


注:本文中的django.contrib.admin.ModelAdmin.changelist_view方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。