code: def has_permission(self, request):
          
          if not self.object and not self.permission:
              return True
  
          if not self.permission:
              return request.user.has_perm('{}_{}'.format(
                  self.model_permission,
                  self.object.__class__.__name__.lower()), self.object
              )
  
          return request.user.has_perm(self.permission)
docs: Check if user has permission