code: def perm_to_permission(perm):
      
      from django.contrib.auth.models import Permission
      try:
          app_label, codename = perm.split('.', 1)
      except (ValueError, IndexError):
          raise AttributeError(
              'The format of identifier string permission (perm) is wrong. '
              "It should be in 'app_label.codename'."
          )
      else:
          permission = Permission.objects.get(
              content_type__app_label=app_label,
              codename=codename
          )
          return permission
docs: Convert a permission-string to a permission instance.
  
      Examples
      --------
      >>> permission = perm_to_permission('auth.add_user')
      >>> permission.content_type.app_label
      'auth'
      >>> permission.codename
      'add_user'