Vijay, Thanks a lot. That helped.
- Shekar On Sunday, 3 May 2015 15:27:58 UTC-7, Vijay Khemlani wrote: > > user_passes_test is for decorating functions, not classes > > Django Rest Framework has its own system for permissions (and you seem to > be already using it) > > http://www.django-rest-framework.org/api-guide/permissions/ > > Use that instead I think > > On Sun, May 3, 2015 at 2:35 PM, Shekar Tippur <cti...@gmail.com > <javascript:>> wrote: > >> Hello, >> >> 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:GETRequest URL:http://127.0.0.1:8000/users/Django Version: >> 1.8Exception Type:TypeErrorException 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 252Python Executable: >> /Library/Frameworks/Python.framework/Versions/3.4/bin/python3.4Python >> Version:3.4.3Python 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'] >> >> >> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to django-users...@googlegroups.com <javascript:>. >> To post to this group, send email to django...@googlegroups.com >> <javascript:>. >> Visit this group at http://groups.google.com/group/django-users. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/django-users/ee405db3-8ace-4f10-8bc3-a72b81ed9fc2%40googlegroups.com >> >> <https://groups.google.com/d/msgid/django-users/ee405db3-8ace-4f10-8bc3-a72b81ed9fc2%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a0b0b94b-1bc7-4864-b624-1b877578cb1d%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.