from app.models import CustomUser
from django.contrib.auth.models import User, Permission
user = CustomUser.objects.get(username='new.user')
custom_permission = Permission.objects.get(codename='is_custom')
user.user_permissions.add(custom_permission)
user.save()
user.has_perm(custom_permission)
user.has_perm('app.is_custom')
user.get_all_permissions()
Unable to set custom permissions in Django