def get_object(self):
        queryset = self.get_queryset()

        url_kwarg = self.lookup_url_kwarg or self.lookup_field
        name_attr = self.switch_user_group('username', 'name')

        for obj in queryset:
            auth_obj = obj[self.get_user_or_group()]

            if self.kwargs[url_kwarg] == getattr(auth_obj, name_attr):
                return obj

        raise Http404('No permissions found for %s' % self.kwargs[url_kwarg])
dataset/ETHPy150Open stackdio/stackdio/stackdio/core/viewsets.py/StackdioBasePermissionsViewSet.get_object/original