本文整理汇总了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)