How to Host Access Django project to run in a virtual machine

Note: Close windows Defender firewall

How to Host Access Django project to run in a virtual machine **

By python manage.py runserver to start Django comes with the test server, the IP address of 127.0.0.0:8000. In the browser address bar enter the host 127.0.0.0:8000, but life and death do not see Demo run. (I am a rookie, prawns do not laughed) is actually very simple question, but at the time was head of a tendon fiddle for a long time there has been no clue.

In fact, when you start the test type python manage.py runserver 0.0.0.0:8000 server or python manage.py runserver ip: port (ip virtual machine ip address, port number, their own definition), then enter the host browser address bar ip: port (ip virtual machine ip address, port number for the previously defined port number), then you can see the Django Demo program the "It 's works!"

If theDisallowedHost at /test

Go to settings file

The ALLOWED_HOSTS = [] to ALLOWED_HOSTS = [ '*']

On it

If you want to use the domain name into the way

Modify the hosts file, directory C:\Windows\System32\drivers\etc, the first copy of a copy, in case of emergency, and then edit it, if not to modify, copy it to the desktop, change over and put back

Modify the content as: Add at the bottom 虚拟机的ip地址 自定义的域名

such as: 202.108.22.5 www.baidu.com

On it, then enter the domain name in the browser: port number, you can access the

Guess you like

Origin www.cnblogs.com/lucky75/p/11373420.html
Recommended