def add_permissions(user, permissions):
 for permission in permissions:
  (app_label, __, codename) = permission.partition('.')
  perm = Permission.objects.get(content_type__app_label=app_label, codename=codename)
  user.user_permissions.add(perm)

def add_permissions ( user , permissions ) : for permission in permissions : ( app_label , __ , codename ) = permission . partition ( '.' ) perm = Permission . objects . get ( content_type__app_label = app_label , codename = codename ) user . user_permissions . add ( perm )
grant permissions to the passed user .