我有Django 1.7,当我向django提交POST请求时,我一直收到此错误。
如果Debug为true,那么我不会收到任何错误。
我已经看过这个
了Setting DEBUG = False causes 500 Error
我在ALLOWED_HOST
添加了所有地址,但我一直收到错误
[Django] ERROR (EXTERNAL IP): Internal Server Error:
Internal Server Error: /api/user/edit
Traceback (most recent call last):
File "/srv/vhosts/site1/env/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 204, in get_response
response = middleware_method(request, response)
File "/srv/vhosts/site1/env/local/lib/python2.7/site-packages/htmlmin/middleware.py", line 41, in process_response
if minify and self.can_minify_response(request, response):
File "/srv/vhosts/site1/env/local/lib/python2.7/site-packages/htmlmin/middleware.py", line 32, in can_minify_response
resp_ok = resp_ok and 'text/html' in response['Content-Type']
File "/srv/vhosts/site1/env/local/lib/python2.7/site-packages/django/http/response.py", line 187, in __getitem__
return self._headers[header.lower()][1]
KeyError: 'content-type'
Request repr():
<WSGIRequest
path://api/user/edit,
GET:<QueryDict: {}>,
POST:<QueryDict: {}>,
COOKIES:{'csrftoken': 'HN2zP9edr2ItI5uW6tMocemUBczPiN4C',
'sessionid': 'y10w8jqqertztttrol63bqtjfj8qa4c6'},
META:{'CONTENT_LENGTH': '37',
'CONTENT_TYPE': 'application/json;charset=UTF-8',
u'CSRF_COOKIE': u'HN2zP9edr2ItI5uW6tMocemUBczPiN4C',
'HTTP_ACCEPT': 'application/json, text/plain, */*',
'HTTP_ACCEPT_ENCODING': 'gzip, deflate',
'HTTP_ACCEPT_LANGUAGE': 'en-GB,en-US;q=0.8,en;q=0.6',
'HTTP_CONNECTION': 'close',
'HTTP_COOKIE': 'sessionid=y10w8jqqertztttrol63bqtjfj8qa4c6; csrftoken=HN2zP9edr2ItI5uW6tMocemUBczPiN4C',
'HTTP_HOST': '104.60.4.102',
'HTTP_ORIGIN': 'https://104.60.4.102,
'HTTP_REFERER': 'https://104.60.4.102/users/',
'HTTP_USER_AGENT': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36',
'HTTP_X_CSRFTOKEN': 'HN2zP9edr2ItI5uW6tMocemUBczPiN4C',
'HTTP_X_FORWARDED_FOR': '104.60.4.160',
'PATH_INFO': u'//api/user/edit',
'QUERY_STRING': '',
'RAW_URI': '/api/user/edit',
'REMOTE_ADDR': '',
'REQUEST_METHOD': 'POST',
'SCRIPT_NAME': u'',
'SERVER_NAME': '104.60.4.102',
'SERVER_PORT': '80',
'SERVER_PROTOCOL': 'HTTP/1.0',
'SERVER_SOFTWARE': 'gunicorn/19.0.0',
'gunicorn.socket': <socket._socketobject object at 0x5daa910>,
'wsgi.errors': <gunicorn.http.wsgi.WSGIErrorsWraper object at 0x5dbae10>,
'wsgi.file_wrapper': <class 'gunicorn.http.wsgi.FileWrapper'>,
'wsgi.input': <gunicorn.http.body.Body object at 0x5dbaf10>,
'wsgi.multiprocess': True,
'wsgi.multithread': False,
'wsgi.run_once': False,
'wsgi.url_scheme': 'http',
'wsgi.version': (1, 0)}>
如果可能是问题,则REMOTE_ADDR将显示为''
数据很好地发布到数据库但我在firebug中得到了错误
答案 0 :(得分:1)
Django-HTMLMin似乎期望密钥content-type
应以大写字母开头。
因此,请查看您是否自行设置标题content-type
,如果是,请更改为Content-Type
。
我在存储库中为您快速搜索了Django HTMLMIN repo