django基本介绍
1.django项目创建
- django-admin startproject crm
(djangovirtualenv) pyvip@VIP:~/django$ django-admin startproject crm
(djangovirtualenv) pyvip@VIP:~/django$ tree
.
├── crm
│ ├── crm
│ │ ├── __init__.py
│ │ ├── settings.py
│ │ ├── urls.py
│ │ └── wsgi.py
│ └── manage.py
2.django启动服务
- python manage.py runserver 0.0.0.0:8000
(djangovirtualenv) pyvip@VIP:~/django$ cd crm
(djangovirtualenv) pyvip@VIP:~/django/crm$ python manage.py runserver 0.0.0.0:8000
Performing system checks...
System check identified no issues (0 silenced).
You have 15 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
Run 'python manage.py migrate' to apply them.
February 16, 2019 - 14:05:54
Django version 2.1.7, using settings 'crm.settings'
Starting development *server* at http://0.0.0.0:8000/
Quit the server with CONTROL-C.
此时可以在浏览器上通过127.0.0.1:8000访问了,出现 The install worked successfully! Congratulations! 代表访问成功
3.创建应用
- python manage.py startapp teacher
(djangovirtualenv) pyvip@VIP:~/django/crm$ python manage.py startapp teacher
(djangovirtualenv) pyvip@VIP:~/django/crm$ tree
.
├── crm
│ ├── __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
└── teacher
├── admin.py
├── apps.py
├── __init__.py
├── migrations
│ └── __init__.py
├── models.py
├── tests.py
└── views.py