关于python:实战python-django开发web

3次阅读

共计 1041 个字符,预计需要花费 3 分钟才能阅读完成。

0x01 环境搭建

1、筹备

sudo pip3 install -U pip
pip install django
pip install ipython mysqlclient

2、创立我的项目

django-admin startproject myProject  // 创立我的项目
cd myProject
python3 manage.py startapp myApp  // 创立利用 

3、启动

python3 manage.py runserver 0:8080

4、根本目录构造

myProject
├── db.sqlite3
├── manage.py
├── myApp
│   ├── admin.py
│   ├── apps.py
│   ├── __init__.py
│   ├── migrations
│   │   ├── 0001_initial.py
│   │   ├── __init__.py
│   │   └── __pycache__
│   │       ├── 0001_initial.cpython-35.pyc
│   │       └── __init__.cpython-35.pyc
│   ├── models.py
│   ├── __pycache__
│   │   ├── admin.cpython-35.pyc
│   │   ├── apps.cpython-35.pyc
│   │   ├── __init__.cpython-35.pyc
│   │   ├── models.cpython-35.pyc
│   │   └── views.cpython-35.pyc
│   ├── templates
│   │   └── myApp
│   │       └── detail.html
│   ├── tests.py
│   └── views.py
└── myProject
    ├── __init__.py
    ├── __pycache__
    │   ├── __init__.cpython-35.pyc
    │   ├── settings.cpython-35.pyc
    │   ├── urls.cpython-35.pyc
    │   └── wsgi.cpython-35.pyc
    ├── settings.py
    ├── urls.py
    └── wsgi.py

5、其余

  • 应用 ipython 接口

python3 manage.py makemigrations myApp

  • 在 models 里进行了数据库的批改当前
python3 manage.py makemigrations myApp
python3 manage.py sqlmigrate myApp 0001
python3 manage.py migrate

0x02 实战我的项目

1、booklist
知识点:数据库操作

参考资料:
https://www.lanqiao.cn/course…

正文完
 0