I have a function that i want to be accessed only if the user is a supersuser.
I have tried this
from django.contrib.admin.views.decorators import staff_member_required
@staff_member_required
def my_view(request):
template_name = 'Core\CustomizedAdmin.html'
return render(request, template_name)
What happens is that when i try to access this view, it directs me to the default login admin page.
And then when i login as a superuser, it gives an OSError invalid argument:
I expected that after login in as a superuser it will redirect to the Page i want.
Am i doing it the wrong way?
Is there an alternative way to Limit a view to superuser only?