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