Reputation: 5764
In my Django application, I have 3 types of roles(groups)
Superuser AccountAdmin ShopAdmin
I want that, superuser can access to every url, but other 2 admins cannot access /su/* urls.
How can I do that?
Upvotes: 4
Views: 5992
Reputation: 31951
from django.contrib.auth.decorators import user_passes_test
@user_passes_test(lambda u: u.is_superuser)
def your_su_view(request):
pass
Upvotes: 5