Is it possible to set permission_classes for OR relation

23 views
Skip to first unread message

William Huang

unread,
Jul 19, 2017, 1:29:47 PM7/19/17
to Django REST framework
Hi All,

Is it possible to set permission_classes for OR relation ?
for example I want to allow a logged in user or an admin user to this view, so I set:

permission_classes = (IsAuthenticated, IsAdminUser)

Is this correct?

Thank you!

Xavier Ordoquy

unread,
Jul 20, 2017, 3:56:55 AM7/20/17
to django-res...@googlegroups.com
Hi,

You’ll need to implement an intermediate permission classe that would perform the OR and delegate the permission check to the subclasses.

Regards,
Xavier Ordoquy,
Linovia.

--
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-fram...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Joel Bennett

unread,
Jan 16, 2019, 4:19:43 PM1/16/19
to Django REST framework
I know I'm a little late to the party here, but the documentation in this regard isn't exactly clear.  From the current docs:

Provided they inherit from rest_framework.permissions.BasePermission, permissions can be composed using standard Python bitwise operators

So far I haven't been able to get this to work either, despite both my permissions inheriting from BasePermission.
 

On Thursday, July 20, 2017 at 1:56:55 AM UTC-6, Xavier Ordoquy wrote:
Hi,

You’ll need to implement an intermediate permission classe that would perform the OR and delegate the permission check to the subclasses.

Regards,
Xavier Ordoquy,
Linovia.
Le 19 juil. 2017 à 19:29, William Huang <willia...@gmail.com> a écrit :

Hi All,

Is it possible to set permission_classes for OR relation ?
for example I want to allow a logged in user or an admin user to this view, so I set:

permission_classes = (IsAuthenticated, IsAdminUser)

Is this correct?

Thank you!

--
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages