0

如何使用视图自定义 django 管理列表页面以及如何在模板 change_list.html 中传递值以在django 管理列表页面中显示新字段

我试图在管理员中编写列表视图:

def get_urls(self):
        urls = super(BeneficiaryAdmin, self).get_urls()
        my_urls = patterns('',
            (r'^list_view/$', self.list_view)
        )
        return my_urls + urls

def list_view(self, request):
        print "kkkkkkkkkkkkkkkkkkkkkkkkkk"
        # custom view which should return an HttpResponse
        return HttpResponseRedirect("/dashboard/member_management/beneficiary/")

但是 list_view 是不可调用的。

4

2 回答 2

0

你读过Overriding admin templates吗?

于 2012-07-25T06:23:54.537 回答
0
def changelist_view(self, request, extra_context=None):
        from django.contrib.admin.views.main import ChangeList
        cl = ChangeList(request, self.model, list(self.list_display), 
                        self.list_display_links, self.list_filter, 
                        self.date_hierarchy, self.search_fields,  
                        self.list_select_related, 
                        self.list_per_page, 
                        self.list_editable, 
                        self)

        if extra_context is None: 
            extra_context = {}
return super(BeneficiaryAdmin, self).changelist_view(request, extra_context=extra_context)

我们可以使用它来编辑列表视图页面。

于 2012-07-25T09:13:19.593 回答