MCPcopy
hub / github.com/django/django / has_view_permission

Method has_view_permission

django/contrib/admin/options.py:645–661  ·  view source on GitHub ↗

Return True if the given request has permission to view the given Django model instance. The default implementation doesn't examine the `obj` parameter. If overridden by the user in subclasses, it should return True if the given request has permission to vie

(self, request, obj=None)

Source from the content-addressed store, hash-verified

643 return request.user.has_perm("%s.%s" % (opts.app_label, codename))
644
645 def has_view_permission(self, request, obj=None):
646 """
647 Return True if the given request has permission to view the given
648 Django model instance. The default implementation doesn't examine the
649 `obj` parameter.
650
651 If overridden by the user in subclasses, it should return True if the
652 given request has permission to view the `obj` model instance. If `obj`
653 is None, it should return True if the request has permission to view
654 any object of the given type.
655 """
656 opts = self.opts
657 codename_view = get_permission_codename("view", opts)
658 codename_change = get_permission_codename("change", opts)
659 return request.user.has_perm(
660 "%s.%s" % (opts.app_label, codename_view)
661 ) or request.user.has_perm("%s.%s" % (opts.app_label, codename_change))
662
663 def has_view_or_change_permission(self, request, obj=None):
664 return self.has_view_permission(request, obj) or self.has_change_permission(

Callers 7

formfield_for_dbfieldMethod · 0.45
get_model_permsMethod · 0.45
render_change_formMethod · 0.45
get_inline_formsetsMethod · 0.45
has_view_permissionMethod · 0.45
has_permMethod · 0.45

Calls 2

get_permission_codenameFunction · 0.90
has_permMethod · 0.45

Tested by

no test coverage detected