code: def remove_historical_group_permissions(group=None, allowed_permissions=None):
      
      allowed_permissions = allowed_permissions or ["view"]
  
      for action in allowed_permissions:
          for permission in group.permissions.filter(
              codename__contains="historical"
          ).exclude(codename__startswith=action):
              group.permissions.remove(permission)
docs: Removes group permissions for historical models
      except those whose prefix is in `allowed_historical_permissions`.
  
      Default removes all except `view`.