[Answered ]-Adding permissions when user is saved in Django Rest Framework

2👍

You’re calling has_perm incorrectly. It expects a string in this format

"<app label>.<permission codename>"

As an aside, may I recommend to simplify your code like so:

codenames = 'view_restaurant', 'change_restaurant', ...
perms = Permission.objects.filter(codename__in=codenames)
user.user_permissions.add(*perms)
👤wim

Leave a comment