Here is a decorator that I am trying ot use to restrict access to the class to only super users: Can someone please point me to what could be wrong. If I take the decorator, I am able to get thro but it is not restricted to only super users.
@user_passes_test(lambda u: u.is_superuser)
class UserViewSet(viewsets.ModelViewSet):
permission_classes = [permissions.TokenHasReadWriteScope]
queryset = User.objects.all()
serializer_class = UserSerializer
model=User
When I use this, I get the error:
'type' object is not iterable
TypeError at /users/
'type' object is not iterable
Request Method: | GET |
---|
Request URL: | http://127.0.0.1:8000/users/ |
---|
Django Version: | 1.8 |
---|
Exception Type: | TypeError |
---|
Exception Value: | 'type' object is not iterable |
---|
Exception Location: | /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/rest_framework/views.py in get_permissions, line 252 |
---|
Python Executable: | /Library/Frameworks/Python.framework/Versions/3.4/bin/python3.4 |
---|
Python Version: | 3.4.3 |
---|
Python Path: | ['/Users/PycharmProjects/screens',
'/Users/PycharmProjects/screens',
'/Library/Frameworks/Python.framework/Versions/3.4/lib/python34.zip',
'/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4',
'/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/plat-darwin',
'/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/lib-dynload',
'/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages']
|
---|