这是我的观点.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)
希望有帮助。
我是一名优秀的程序员,十分优秀!