本文整理匯總了Python中django.contrib.admin.actions.delete_selected方法的典型用法代碼示例。如果您正苦於以下問題:Python actions.delete_selected方法的具體用法?Python actions.delete_selected怎麽用?Python actions.delete_selected使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類django.contrib.admin.actions
的用法示例。
在下文中一共展示了actions.delete_selected方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_actions
# 需要導入模塊: from django.contrib.admin import actions [as 別名]
# 或者: from django.contrib.admin.actions import delete_selected [as 別名]
def get_actions(self, request):
actions = super().get_actions(request)
def subadmin_delete_selected(modeladmin, req, qs):
response = delete_selected(modeladmin, req, qs)
if response:
response.context_data.update(self.context_add_parent_data(request))
return response
if 'delete_selected' in actions:
actions['delete_selected'] = (subadmin_delete_selected, 'delete_selected', actions['delete_selected'][2])
return actions
示例2: __init__
# 需要導入模塊: from django.contrib.admin import actions [as 別名]
# 或者: from django.contrib.admin.actions import delete_selected [as 別名]
def __init__(self, name='admin'):
self._registry = {} # model_class class -> admin_class instance
self.name = name
self._actions = {'delete_selected': actions.delete_selected}
self._global_actions = self._actions.copy()
示例3: __init__
# 需要導入模塊: from django.contrib.admin import actions [as 別名]
# 或者: from django.contrib.admin.actions import delete_selected [as 別名]
def __init__(self, name='admin'):
self._registry = {} # model_class class -> admin_class instance
self.name = name
self._actions = {'delete_selected': actions.delete_selected}
self._global_actions = self._actions.copy()
all_sites.add(self)
示例4: __init__
# 需要導入模塊: from django.contrib.admin import actions [as 別名]
# 或者: from django.contrib.admin.actions import delete_selected [as 別名]
def __init__(self, django_site, name='admino'):
self.django_site = django_site
self._registry = {}
self.name = name
self._actions = {'delete_selected': actions.delete_selected}
self._global_actions = self._actions.copy()
示例5: get_actions
# 需要導入模塊: from django.contrib.admin import actions [as 別名]
# 或者: from django.contrib.admin.actions import delete_selected [as 別名]
def get_actions(self, request):
actions = super().get_actions(request)
if 'delete_selected' in actions:
del actions['delete_selected']
return actions
示例6: delete_selected_action
# 需要導入模塊: from django.contrib.admin import actions [as 別名]
# 或者: from django.contrib.admin.actions import delete_selected [as 別名]
def delete_selected_action(self, model_admin, request, qs):
objects = UsersTasksValidationAdmin.QSList(qs)
if request.POST.get('post'):
deletable_objects, model_count, perms_needed, protected = get_deleted_objects(
objects, request, model_admin.admin_site)
if not protected:
res = delete_selected(model_admin, request, objects)
for obj in objects:
self.on_object_deleted(obj)
return res
response = delete_selected(model_admin, request, objects)
context = response.context_data
context['running_tasks'] = self.get_user_task_names() or None
return TemplateResponse(request, model_admin.delete_selected_confirmation_template, context)
示例7: delete_selected
# 需要導入模塊: from django.contrib.admin import actions [as 別名]
# 或者: from django.contrib.admin.actions import delete_selected [as 別名]
def delete_selected(self, request, queryset):
if 'hard_delete' in dir(queryset):
queryset.delete = queryset.hard_delete
return delete_selected_(self, request, queryset)
示例8: test_disable_action
# 需要導入模塊: from django.contrib.admin import actions [as 別名]
# 或者: from django.contrib.admin.actions import delete_selected [as 別名]
def test_disable_action(self):
action_name = 'delete_selected'
self.assertEqual(self.site._actions[action_name], delete_selected)
self.site.disable_action(action_name)
with self.assertRaises(KeyError):
self.site._actions[action_name]
示例9: test_get_action
# 需要導入模塊: from django.contrib.admin import actions [as 別名]
# 或者: from django.contrib.admin.actions import delete_selected [as 別名]
def test_get_action(self):
"""AdminSite.get_action() returns an action even if it's disabled."""
action_name = 'delete_selected'
self.assertEqual(self.site.get_action(action_name), delete_selected)
self.site.disable_action(action_name)
self.assertEqual(self.site.get_action(action_name), delete_selected)