I updated my django from 1.7 to 1.8 and my server isn't running anymore.
What I did:
- Tried to install python 3.6: nothing happened after I run the installer.
- Uninstalled Django 1.7 and installed 1.9. Unfortunately this version brings me trouble (server didn't even starts).
- Uninstalled 1.9 and installed 1.8. Now it's getting this error.
I'm on a macOS Sierra. 10.12.3. My python version is 2.7.
I need version 1.8 of Django in order to use the 'from rest_framwork.view import APIView'
Can someone help me?
Here's the log:
System check identified no issues (0 silenced).
April 09, 2017 - 01:35:43
Django version 1.8.18, using settings 'connectedin.settings'
Starting development server at http://192.168.0.101:8000/
Quit the server with CONTROL-C.
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/wsgiref/handlers.py", line 85, in run
self.result = application(self.environ, self.start_response)
File "/Library/Python/2.7/site-packages/Django-1.8.18-py2.7.egg/django/contrib/staticfiles/handlers.py", line 63, in __call__
return self.application(environ, start_response)
File "/Library/Python/2.7/site-packages/Django-1.8.18-py2.7.egg/django/core/handlers/wsgi.py", line 189, in __call__
response = self.get_response(request)
File "/Library/Python/2.7/site-packages/Django-1.8.18-py2.7.egg/django/core/handlers/base.py", line 207, in get_response
return debug.technical_500_response(request, *sys.exc_info(), status_code=400)
File "/Library/Python/2.7/site-packages/Django-1.8.18-py2.7.egg/django/views/debug.py", line 97, in technical_500_response
html = reporter.get_traceback_html()
File "/Library/Python/2.7/site-packages/Django-1.8.18-py2.7.egg/django/views/debug.py", line 384, in get_traceback_html
return t.render(c)
File "/Library/Python/2.7/site-packages/Django-1.8.18-py2.7.egg/django/template/base.py", line 210, in render
return self._render(context)
File "/Library/Python/2.7/site-packages/Django-1.8.18-py2.7.egg/django/template/base.py", line 202, in _render
return self.nodelist.render(context)
File "/Library/Python/2.7/site-packages/Django-1.8.18-py2.7.egg/django/template/base.py", line 905, in render
bit = self.render_node(node, context)
File "/Library/Python/2.7/site-packages/Django-1.8.18-py2.7.egg/django/template/debug.py", line 79, in render_node
return node.render(context)
File "/Library/Python/2.7/site-packages/Django-1.8.18-py2.7.egg/django/template/defaulttags.py", line 329, in render
return nodelist.render(context)
File "/Library/Python/2.7/site-packages/Django-1.8.18-py2.7.egg/django/template/base.py", line 905, in render
bit = self.render_node(node, context)
File "/Library/Python/2.7/site-packages/Django-1.8.18-py2.7.egg/django/template/debug.py", line 79, in render_node
return node.render(context)
File "/Library/Python/2.7/site-packages/Django-1.8.18-py2.7.egg/django/template/debug.py", line 89, in render
output = self.filter_expression.resolve(context)
File "/Library/Python/2.7/site-packages/Django-1.8.18-py2.7.egg/django/template/base.py", line 648, in resolve
obj = self.var.resolve(context)
File "/Library/Python/2.7/site-packages/Django-1.8.18-py2.7.egg/django/template/base.py", line 789, in resolve
value = self._resolve_lookup(context)
File "/Library/Python/2.7/site-packages/Django-1.8.18-py2.7.egg/django/template/base.py", line 849, in _resolve_lookup
current = current()
File "/Library/Python/2.7/site-packages/Django-1.8.18-py2.7.egg/django/http/request.py", line 152, in build_absolute_uri
host=self.get_host(),
File "/Library/Python/2.7/site-packages/Django-1.8.18-py2.7.egg/django/http/request.py", line 102, in get_host
raise DisallowedHost(msg)
DisallowedHost: Invalid HTTP_HOST header: '192.168.0.101:8000'. You may need to add u'192.168.0.101' to ALLOWED_HOSTS.
[09/Apr/2017 01:35:51] "GET / HTTP/1.1" 500 59
Looks like you need the ALLOWED_HOSTS
settings
This behavior changed between django 1.7] and django 1.8
When DEBUG is True or when running tests, host validation is disabled; any host will be accepted. Thus it's usually only necessary to set it in production.
When DEBUG is True and ALLOWED_HOSTS is empty, the host is validated against ['localhost', '127.0.0.1', '[::1]']
You need to add this IP address to this setting
Something on the lines of:
ALLOWED_HOSTS = ['192.168.0.101', 'localhost', '127.0.0.1', '[::1]']
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.