Python library Django links mysql database to make website (2)--insert data from web page to database

Python uses the Django library to collect data from web pages and insert it into the mysql database

1. Directory structure
Description: After the directory structure has been optimized, it has become the basic layout of model+html+views.
Baidu network disk link: https://pan.baidu.com/s/1uWRDyIZmDdGFkHskBEncEQ
Extraction code: ikuc
insert image description here
2. Implementation step
1. Create entity class
insert image description here
2. Execute the following three commands to create a database table
python manage.py makemigrations
python manage. py makemigrations web_t
python manage.py migrate
This command is executed sequentially after entering the root directory of the project in cmd, and the execution of cmd commands will not be introduced in detail.
When you see a string of ok, it’s all right, basically loading some library tables that Django depends on.

3. Views storage logic
insert image description here
4. Page implementation
insert image description here
5. Access settings
insert image description here
6. Access test
insert image description here

Guess you like

Origin blog.csdn.net/lishihuijava/article/details/88023254