I am not using django built-in admin panel for the admin page but I am trying to add functionality like django-admin.I want to restrict normal users to the admin app and for this I check like this if not request.user.is_superuser in every function where I want to restrict.It does the job pretty well but in the app there can be so many functions and i have to check this in every function inside the app and I think this should not be the good solution.So is there any solution so that I can give access the whole admin functionality to only superuser without checking user with if not request.user.is_superuser in every function inside the admin app ?
views.py
def a(request):
if not request.user.is_superuser:
return redirect('login')
..........
def b(request):
if not request.user.is_superuser:
return redirect('login')
.............
def c(request):
if not request.user.is_superuser:
return redirect('login')
...........
def d(request):
if not request.user.is_superuser:
return redirect('login')
....