0

我正在使用 Django-Subdomain 包,每次'WSGIRequest' object has no attribute 'subdomain'运行此视图时都会收到此错误。

    def post(self, request):
    register_form = StaffRegisterationForm(request.POST)

    if register_form.is_valid():
        staff = register_form.save()
        print(dir(request))
        return redirect('account:dashboard',     subdomain=request.subdomain)
    else:
        print(register_form.errors)
        return HttpResponse('form is invalid')

这是我在设置文件中的中间件:

    MIDDLEWARE = [

'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'subdomains.middleware.SubdomainURLRoutingMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',]
4

0 回答 0