本文整理汇总了Python中django.contrib.admin.ModelAdmin.delete_view方法的典型用法代码示例。如果您正苦于以下问题:Python ModelAdmin.delete_view方法的具体用法?Python ModelAdmin.delete_view怎么用?Python ModelAdmin.delete_view使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.contrib.admin.ModelAdmin
的用法示例。
在下文中一共展示了ModelAdmin.delete_view方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: delete_view
# 需要导入模块: from django.contrib.admin import ModelAdmin [as 别名]
# 或者: from django.contrib.admin.ModelAdmin import delete_view [as 别名]
def delete_view(self, request, object_id, extra_context=None):
"The 'delete' admin view for this model."
blocked = []
blocked_related = []
obj = self.model.objects.get(id=object_id)
if not self.is_authorized(request.user, obj):
blocked = [ obj ]
if not blocked:
blocked_related = self.related_not_authorized(request.user, [obj])
if not blocked_related:
## let default Admin delete_view handle all other cases
return ModelAdmin.delete_view(self, request, object_id,
extra_context=extra_context)
return self.delete_blocked_response(request, [obj], blocked, blocked_related,
template='delete_blocked.html')