django-admin startproject my_tennis_club
python3 manage.py runserver
python3 manage.py startapp members
Migrate
python3 manage.py makemigrations members
python3 manage.py migrate
View SQL
python3 manage.py sqlmigrate members 0001
python3 manage.py shell
Add the code
from members.models import Member
Member.objects.all()
member1 = Member(first_name='K', last_name='Shahin', email='k.shahin@gmail.com', phone='1234567890', date_of_birth='2024-03-27')
member2 = Member(first_name='L', last_name='Shahin', email='l.shahin@gmail.com', phone='1234567890', date_of_birth='2024-03-27')
member3 = Member(first_name='M', last_name='Shahin', email='m.shahin@gmail.com', phone='1234567890', date_of_birth='2024-03-27')
members_list = [member1, member2, member3]
for x in members_list:
x.save()
Member.objects.all().values()
x = Member.objects.all()[0]
x.phone = '9876543210'
x.save()
x = Member.objects.all()[2]
x.delete()
To add a field to a table after it is created, need to make changes in models.py
and then need to update migrations.