2017-09-06 38 views
0

瀏覽器發送OPTIONS請求,我得到這個奇怪的錯誤。什麼是可能的錯誤?測試在Django的1.10和1.11Django'dict'對象沒有屬性'set_cookie'

ERROR Internal Server Error: /cc_login/ 
Traceback (most recent call last): 
    File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/exception.py", line 41, in inner 
    response = get_response(request) 
    File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/base.py", line 249, in _legacy_get_response 
    response = self._get_response(request) 
    File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/base.py", line 187, in _get_response 
    response = self.process_exception_by_middleware(e, request) 
    File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/base.py", line 185, in _get_response 
    response = wrapped_callback(request, *callback_args, **callback_kwargs) 
    File "/usr/local/lib/python3.5/dist-packages/django/utils/decorators.py", line 167, in _wrapped_view 
    return middleware.process_response(request, response) 
    File "/usr/local/lib/python3.5/dist-packages/django/middleware/csrf.py", line 328, in process_response 
    self._set_token(request, response) 
    File "/usr/local/lib/python3.5/dist-packages/django/middleware/csrf.py", line 192, in _set_token 
    response.set_cookie(
AttributeError: 'dict' object has no attribute 'set_cookie' 
[06/Sep/2017 10:50:45] "OPTIONS /cc_login/ HTTP/1.1" 500 12601 

``` 按照要求:

MIDDLEWARE_CLASSES = (
    'cluster.templatetags.ranges.RangeMiddleware', 
    'django.middleware.common.CommonMiddleware', 
    'django.contrib.sessions.middleware.SessionMiddleware', 
    'django.middleware.csrf.CsrfViewMiddleware', 
    'django.contrib.auth.middleware.AuthenticationMiddleware', 
    'django.contrib.messages.middleware.MessageMiddleware', 
    'cluster.templatetags.middleware.LastSeenMiddleware', 
    'django.middleware.gzip.GZipMiddleware', 
    # Uncomment the next line for simple clickjacking protection: 
    # 'django.middleware.clickjacking.XFrameOptionsMiddleware', 
) 

```

+0

發佈導致此錯誤的代碼。 –

+1

'settings.py'中的'MIDDLEWARE_CLASSES'是什麼?有些東西可能會摧毀你的響應對象... –

+0

我不確定我是否在我的代碼中做了任何事情。除設置外。 – x1site

回答

0

我想請求仍然在Django,但到了請求處理這無法處理選項