基于 turndjango class 的视图分派 ValueError

turndjango class based view dispatch ValueError

我的看法class是这样的:

class RecoedView(View):
    isbn = None

    def dispatch(self, request, *args, **kwargs):
        self.isbn = '9754654323456'
        super(RecordView, self).dispatch(request, *args, **kwargs)

    def get(self, request, *args, **kwargs):
        return HttpResponse('This is get')

    def post(self, request, *args, **kwargs):
        return HttpResponse('This is post')

当我 运行 我的视图重写调度方法时,我得到以下错误。

ValueError: The view ils.views.RecordView didn't return an HttpResponse object. It returned None instead.

为什么我会收到这个。请让我明白

您实际上需要 return 超级调用的结果。

return super(RecordView, self).dispatch(request, *args, **kwargs)