Python Django Mysql - CRUD Example Part 1 - Create and Insert in Mysql Database
ฝัง
- เผยแพร่เมื่อ 11 ก.ย. 2024
- #techlearners
Python Django Mysql
CRUD - Create, Read, Update, Delete
Part 1 Create and Insert
Prerequisite
1. Running DJango project - created
• how to create Python D...
2. Mysql server Installation
• Install latest Mysql -...
Step 1 - Create a database mydjangodb in mysql
Step 2 - Configure database in settings.py file of django project.
Step 3 - Create a template in django app to insert data
Step 4 - Create a view in views.py for above template
Step 5 - Create a url pattern in urls.py of app for above template
Step 6 - Create a Model in models.py file of django project
Step 7 - Run command in the terminal to create migrations
python manage.py makemigrations
Step 8 - Run command in the terminal to migrate databases
Step 9 - In mysql command line view the description of table using desc command
Step 10 - In view.py import model created in models.py
Step 11 - In views.py create insert method to insert data in database
Step 12 - Create url pattern in urls.py of django app for above view
Step 13 - Run server and insert data using template
Step 14 - Login to mysql and query database table to confirm data insertion
Part 2 - Read or Fetch data from database and display on webpage
• Python Django Mysql CR...
TECHLEARNERS BY NEERAJ SAXENA
www.techlearner...