本文整理汇总了Python中django.contrib.admin.ModelAdmin.has_delete_permission方法的典型用法代码示例。如果您正苦于以下问题:Python ModelAdmin.has_delete_permission方法的具体用法?Python ModelAdmin.has_delete_permission怎么用?Python ModelAdmin.has_delete_permission使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.contrib.admin.ModelAdmin
的用法示例。
在下文中一共展示了ModelAdmin.has_delete_permission方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: has_delete_permission
# 需要导入模块: from django.contrib.admin import ModelAdmin [as 别名]
# 或者: from django.contrib.admin.ModelAdmin import has_delete_permission [as 别名]
def has_delete_permission(self, request, obj=None):
"""
Returns True if the given request has permission to change the given
Django model instance, the default implementation doesn't examine the
`obj` parameter.
Can be overridden by the user in subclasses. In such case it should
return True if the given request has permission to delete the `obj`
model instance. If `obj` is None, this should return True if the given
request has permission to delete *any* object of the given type.
"""
r = ModelAdmin.has_delete_permission(self, request, obj)
if obj and r:
r = self.is_authorized(request.user, obj)
return r