新建项目
  • 得到本机ip
tqc@tqc-PC:~/PycharmProjects/django/mblog$ ifconfig

wlp0s20f3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.43.243  netmask 255.255.255.0  broadcast 192.168.43.255

我的ip为192.168.43.243

django-admin startproject mblog
cd mblog
python manage.py startapp mainsite

进入settings.py, 修改:

ALLOWED_HOSTS = ['192.168.43.243:8000','192.168.43.243', 'localhost', '0.0.0.0:8000','0.0.0.0', '127.0.0.1']

继续在终端输入:

python manage.py runserver 0.0.0.0:8000

浏览器:http://192.168.43.243:8000/
Django学习笔记_命令行

manage.py是用来管理网站配置文件的, 是接受命令行的工具程序, mblog文件夹存放重要的配置文件, 包括settings.py, urls.py, wsgi.py , wsgi.py 会和网络服务器沟通