django管理员列表页面视图
如何使用视图自定义django管理员列表页面,以及如何在template change_list.html中传递值以显示新字段,如中所示 我试图在管理中将列表视图写为:django管理员列表页面视图,django,django-admin,Django,Django Admin,如何使用视图自定义django管理员列表页面,以及如何在template change_list.html中传递值以显示新字段,如中所示 我试图在管理中将列表视图写为: def get_urls(self): urls = super(BeneficiaryAdmin, self).get_urls() my_urls = patterns('', (r'^list_view/$', self.list_view) )
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/")
但是列表视图不能调用。你读过吗
我们可以使用此选项编辑列表视图页面。我尝试了列表视图页面的“获取URL”和“我的视图”的编码。为了查看页面,我需要编写管理员视图。你能举一个例子吗?
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)