Environment:
Request Method: GET
Request URL: http://192.168.2.214/accounts/login/?next=/
Django Version: 1.11.6
Python Version: 2.7.12
Installed Applications:
('django.contrib.auth',
'django.contrib.admin',
'django.contrib.contenttypes',
'django.contrib.sessions',
'tsa.events')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'tsa.settings.ChapterMiddleware',
'django.contrib.messages.middleware.MessageMiddleware')
Traceback:
File "/usr/local/lib/python2.7/dist-
packages/django/core/handlers/exception.py"
in inner
41. response = get_response(request)
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py"
in
_legacy_get_response
249. response = self._get_response(request)
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py"
in
_get_response
187. response = self.process_exception_by_middleware(e,
request)
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py"
in
_get_response
185. response = wrapped_callback(request, *callback_args,
**callback_kwargs)
File "
/home/serverad/django14_project/my_django15_project/tsa/events/views.py"
in login_view
185. next=request.GET.get('next', '/'),
chapters=Chapter.objects.all(), error_msg=error_msg)
File
"/home/serverad/django14_project/my_django15_project/tsa/events/views.py"
in render_template
71. return HttpResponse(txt, mimetype=kwds.get('mimetype','text/html'))
File "/usr/local/lib/python2.7/dist-packages/django/http/response.py" in
__init__
301. super(HttpResponse, self).__init__(*args, **kwargs)
Exception Type: TypeError at /accounts/login/
Exception Value: __init__() got an unexpected keyword argument 'mimetype'
答案 0 :(得分:2)
Django 1.7中删除了mimetype
参数。请改用content_type
。
return HttpResponse(txt, content_type=kwds.get('mimetype','text/html'))