本文整理匯總了Python中django.contrib.admin.views.main.ChangeList方法的典型用法代碼示例。如果您正苦於以下問題:Python main.ChangeList方法的具體用法?Python main.ChangeList怎麽用?Python main.ChangeList使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類django.contrib.admin.views.main
的用法示例。
在下文中一共展示了main.ChangeList方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_changelist_instance
# 需要導入模塊: from django.contrib.admin.views import main [as 別名]
# 或者: from django.contrib.admin.views.main import ChangeList [as 別名]
def get_changelist_instance(self, request):
"""
Return a `ChangeList` instance based on `request`. May raise
`IncorrectLookupParameters`.
"""
list_display = self.get_list_display(request)
list_display_links = self.get_list_display_links(request, list_display)
# Add the action checkboxes if any actions are available.
if self.get_actions(request):
list_display = ['action_checkbox'] + list(list_display)
ChangeList = self.get_changelist(request)
return ChangeList(
request,
self.model,
list_display,
list_display_links,
self.get_list_filter(request),
self.date_hierarchy,
self.get_search_fields(request),
self.get_list_select_related(request),
self.list_per_page,
self.list_max_show_all,
self.list_editable,
self,
)
示例2: get_changelist
# 需要導入模塊: from django.contrib.admin.views import main [as 別名]
# 或者: from django.contrib.admin.views.main import ChangeList [as 別名]
def get_changelist(self, request, **kwargs):
"""
Returns the ChangeList class for use on the changelist page.
"""
return AdminViewPermissionChangeList
示例3: get_queryset
# 需要導入模塊: from django.contrib.admin.views import main [as 別名]
# 或者: from django.contrib.admin.views.main import ChangeList [as 別名]
def get_queryset(self, request):
"""
Return a QuerySet of all model instances that can be edited by the
admin site. This is used by changelist_view.
"""
qs = self.model._default_manager.get_queryset()
# TODO: this should be handled by some parameter to the ChangeList.
ordering = self.get_ordering(request)
if ordering:
qs = qs.order_by(*ordering)
return qs
示例4: get_changelist
# 需要導入模塊: from django.contrib.admin.views import main [as 別名]
# 或者: from django.contrib.admin.views.main import ChangeList [as 別名]
def get_changelist(self, request, **kwargs):
"""
Return the ChangeList class for use on the changelist page.
"""
from django.contrib.admin.views.main import ChangeList
return ChangeList
示例5: get_changelist
# 需要導入模塊: from django.contrib.admin.views import main [as 別名]
# 或者: from django.contrib.admin.views.main import ChangeList [as 別名]
def get_changelist(self, request, model, modeladmin):
if getattr(modeladmin, 'get_changelist_instance', None):
return modeladmin.get_changelist_instance(request)
return ChangeList(
request, model, modeladmin.list_display,
modeladmin.list_display_links, modeladmin.list_filter,
modeladmin.date_hierarchy, modeladmin.search_fields,
modeladmin.list_select_related, modeladmin.list_per_page,
modeladmin.list_max_show_all, modeladmin.list_editable, modeladmin,
)
示例6: get_changelist_instance
# 需要導入模塊: from django.contrib.admin.views import main [as 別名]
# 或者: from django.contrib.admin.views.main import ChangeList [as 別名]
def get_changelist_instance(self, request):
"""
Return a `ChangeList` instance based on `request`. May raise
`IncorrectLookupParameters`.
"""
list_display = self.get_list_display(request)
list_display_links = self.get_list_display_links(request, list_display)
# Add the action checkboxes if any actions are available.
if self.get_actions(request):
list_display = ['action_checkbox'] + list(list_display)
sortable_by = self.get_sortable_by(request)
ChangeList = self.get_changelist(request)
return ChangeList(
request,
self.model,
list_display,
list_display_links,
self.get_list_filter(request),
self.date_hierarchy,
self.get_search_fields(request),
self.get_list_select_related(request),
self.list_per_page,
self.list_max_show_all,
self.list_editable,
self,
sortable_by,
)
示例7: get_queryset
# 需要導入模塊: from django.contrib.admin.views import main [as 別名]
# 或者: from django.contrib.admin.views.main import ChangeList [as 別名]
def get_queryset(self, request):
"""
Returns a QuerySet of all model instances that can be edited by the
admin site. This is used by changelist_view.
"""
qs = self.model._default_manager.get_queryset()
# TODO: this should be handled by some parameter to the ChangeList.
ordering = self.get_ordering(request)
if ordering:
qs = qs.order_by(*ordering)
return qs
示例8: get_changelist
# 需要導入模塊: from django.contrib.admin.views import main [as 別名]
# 或者: from django.contrib.admin.views.main import ChangeList [as 別名]
def get_changelist(self, request, **kwargs):
"""
Returns the ChangeList class for use on the changelist page.
"""
from django.contrib.admin.views.main import ChangeList
return ChangeList
示例9: get_changelist
# 需要導入模塊: from django.contrib.admin.views import main [as 別名]
# 或者: from django.contrib.admin.views.main import ChangeList [as 別名]
def get_changelist(self, request, **kwargs):
# This controls how the admin list view works. Override the
# ChangeList to modify ordering, template, etc
return CaseInsensitiveChangeList