gpt4 book ai didi

python - View app.views.MyWizard 未返回 HttpResponse 对象

转载 作者:太空宇宙 更新时间:2023-11-03 18:32:19 25 4
gpt4 key购买 nike

这是我的观点.py:

class OnlyNonLoggedInMixin(object):
def dispatch(self, request, *args, **kwargs):
if request.user.is_authenticated():
return HttpResponseRedirect("/page/")

class MyWizard(OnlyNonLoggedInMixin, SessionWizardView):
def get_template_names(self):
return [TEMPLATES[self.steps.current]]

def done(self, form_list, **kwargs):
form_data = process_form_data(form_list)
return HttpResponseRedirect("/ok/")

为什么会出现此错误以及如何修复它?

The view app.views.MyWizard didn't return an HttpResponse object. 

最佳答案

如果用户未经过身份验证,您的 dispatch() 方法不会返回 HttpResponse 对象:

class OnlyNonLoggedInMixin(object):
def dispatch(self, request, *args, **kwargs):
if request.user.is_authenticated():
return HttpResponseRedirect("/page/")
return super(OnlyNonLoggedInMixin, self).dispatch(
self, request, *args, **kwargs)

希望有帮助。

关于python - View app.views.MyWizard 未返回 HttpResponse 对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22201258/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com