I can’t figure out why the permission required decorator isn’t working. I would like to allow access to a view only for staff members. I have tried
@permission_required('request.user.is_staff',login_url="../admin")
def series_info(request):
...
and also
@permission_required('user.is_staff',login_url="../admin")
def series_info(request):
...
As the superuser, I can access the view, but any users I create as staff can’t access it and are redirected to the login url page. I tested the login_required decorator and that works fine.
permission_required()must be passed a permission name, not a Python expression in a string. Try this instead:Re-read the links you posted;
permission_required()will test if a user has been granted a particular permission. It does not test the attributes of the user object.From http://www.djangobook.com/en/2.0/chapter14/: