def dispatch(self, *args, **kwargs): if not settings.EXPOSE_DIRECTORY_API: raise Http404() return super().dispatch(*args, **kwargs)