建立第一个Django工程---linux中的python
建立第一个Django工程 环境: ip: 192.168.0.92 系统:centos7.5 安装django pip install django 启动一个HelloWorld工程 django-admin.py startproject HelloWorld [root@test2 ~]# ls HelloWorld
查看工程自带的文件
[root@test2 ~]# tree . . `-- HelloWorld |-- HelloWorld | |-- __init__.py | |-- __pycache__ | | |-- __init__.cpython-36.pyc | | |-- settings.cpython-36.pyc | | |-- urls.cpython-36.pyc | | `-- wsgi.cpython-36.pyc | |-- settings.py | |-- urls.py | `-- wsgi.py |-- db.sqlite3 `-- manage.py 3 directories, 10 files
合并
cd /root/HelloWorld/ python manage.py migrate [root@test2 HelloWorld]# python manage.py migrate Operations to perform: Apply all migrations: admin, auth, contenttypes, sessions Running migrations: Applying contenttypes.0001_initial... OK Applying auth.0001_initial... OK Applying admin.0001_initial... OK Applying admin.0002_logentry_remove_auto_add... OK Applying admin.0003_logentry_add_action_flag_choices... OK Applying contenttypes.0002_remove_content_type_name... OK Applying auth.0002_alter_permission_name_max_length... OK Applying auth.0003_alter_user_email_max_length... OK Applying auth.0004_alter_user_username_opts... OK Applying auth.0005_alter_user_last_login_null... OK Applying auth.0006_require_contenttypes_0002... OK Applying auth.0007_alter_validators_add_error_messages... OK Applying auth.0008_alter_user_username_max_length... OK Applying auth.0009_alter_user_last_name_max_length... OK Applying sessions.0001_initial... OK 修改ALLOWED_HOSTS cd /root/HelloWorld/HelloWorld/ [root@test2 HelloWorld]# ls __init__.py __pycache__ settings.py urls.py wsgi.py vi settings.py ALLOWED_HOSTS = ['*'] 将ALLOWED_HOSTS = []改为ALLOWED_HOSTS = ['*'] 启动工程 cd /root/HelloWorld python manage.py runserver 0.0.0.0:8000 浏览器访问:http://192.168.0.92:8000/