title: Django - Multiple permissions in a view
body: <p>I want to create a permission for a view that would verify that the user is either the owner of a shop or an admin. I have already created two permissions which work well when called separately which checks for one that the user is admin and for the other that the user is the owner of the shop. I would now like to make a global condition verifying that one of the two conditions is met.</p>
  <p>Here are my departure conditions :</p>
  <p><strong>utils.py</strong></p>
  <pre><code>class IsOwner(BasePermission):
      &quot;&quot;&quot;
      Check if the user who made the request is owner.
      Use like that : permission_classes = [IsOwner]
      &quot;&quot;&quot;
      def has_permission(self, request, view):
          return request.user and request.user.is_authenticated
      def has_object_permission(self, request, view, obj):
          try:
              user_shop = UserShop.objects.get(user=request.user, shop=obj)
              return True
          except:
              return False
  
  class IsAdmin(BasePermission):
      &quot;&quot;&quot;
      Check if the user who made the request is admin.
      Use like that : permission_classes = [IsAdmin]
      &quot;&quot;&quot;
      def has_permission(self, request, view):
          if not 'Authorization' in request.headers:
              return False
          else:
              return request.user.is_admin
  
  class OwnerView(GenericAPIView):
      &quot;&quot;&quot;
      Check if a user is owner
      &quot;&quot;&quot;
      permission_classes = (IsOwner,)
  
  class AdminView(APIView):
      &quot;&quot;&quot;
      Check if a user is admin
      &quot;&quot;&quot;
      permission_classes = (IsAdmin,)
  </code></pre>
  <p>Here is the function I am trying to do :</p>
  <pre><code>class AdminOrOwnerView(GenericAPIView):
      &quot;&quot;&quot;
      Check if a user is admin or owner
      &quot;&quot;&quot;
      permission_classes = ( IsOwner|IsAdmin,)
  </code></pre>
  <p>Currently, this condition allows any logged in user to use my view</p>
  <p>Here is my view :</p>
  <p><strong>views.py</strong></p>
  <pre><code>class ShopDetail(AdminOrOwnerView):
      &quot;&quot;&quot;Edit ou delete a shop&quot;&quot;&quot;
      queryset = Shop.objects.all()
      lookup_field = 'path'
  
      def put(self, request, path):
          &quot;&quot;&quot;For admin or shop owner to edit a shop&quot;&quot;&quot;
          shop = self.get_object()
          serializer = ShopSerializer(shop, data=request.data)
          if serializer.is_valid():
              serializer.save()
              return Response(serializer.data)
          return Response(serializer.errors)
  </code></pre>
  <p>Thank you in advance for your help</p>