(Essay) Mac environment + Pycharm + Django basic configuration

1. Configure the environment
Step 1. Create a Django project through Pycharm

Step 2, configure the running environment

Click "run" and find "Edit Configurations..."

Click "+" to find the "manage.py" file of the created Django project, select the corresponding python interpreter, and set Parameters to "runserver"

 Step 3. Modify the automatically generated content
(1) Comment the contents in settings.py

 (2) Delete the templates files generated by Django itself.
Step 4, create APP

Click "tools" to find "Run manage.py Task..."

 In the panel, enter

startapp demo1

 Step 5, register APP

 In "INSTALLED_APPS" of "settings.py", register.

Step 6, test 

【1】Create the folder "templates" in "demo1" under the app and create the "test.html" file

【2】Create a function in “views.py” under the app

【3】Add the association relationship in the "urls.py" file under the main project.

 【4】 Open the "manage.py" file under the main project and click "RUN".

【5】Open

2. Try to connect to Mysql and create data
Step 1, create database
create database gx_day16 default charset utf8 COLLATE utf8mb3_general_ci;

Step 2, modify the project configuration file
 Step 3, create table

Step 4, perform the operation

 Execute first: makemigrations

Execute again: migrate

 

Step 5, see the results
 

 

Guess you like

Origin blog.csdn.net/qq_23938507/article/details/131916449