Step 1: Setting Up Your Django Project
I.
Install Django:
First, make sure you have Django installed by running
this command in your terminal:
pip install django
This will install Django on your computer.
Create a New Django Project:
Now, let's start a
new Django project. This is like creating a folder that will hold all the files
for your website. Use this command to create the project and name it
"school_system":
django-admin
startproject school_system
After running this
command, you'll see a new folder named school_system. This folder contains the
basic setup for your Django project.
Create a New App Inside the Project:
In Django, an
"app" is a part of your website that does something specific. Let's
create an app called "dashboard." First, move into the school_system
folder:
cd school_system
Then, create the app
by typing:
python manage.py
startapp dashboard
This will create a
new folder named dashboard where you will store all the files related to the
student information system.
Step 2: Defining the Data (Models)
Create a Student
Model:
A "model"
in Django describes the type of data you want to store in your database. For
example, to store information about students, you'll create a student model.
Open the models.py
file in the "dashboard" folder and add this code:
from django.db
import models
class
Student(models.Model):
student_id =
models.CharField(max_length=20, unique=True)
# This stores the student's ID
first_name =
models.CharField(max_length=50) # This
stores the student's first name
last_name =
models.CharField(max_length=50) # This
stores the student's last name
date_of_birth = models.DateField() # This stores the student's date of birth
email = models.EmailField(unique=True) # This stores the student's email
phone_number =
models.CharField(max_length=15) # This
stores the student's phone number
address = models.TextField() # This stores the student's home address
def __str__(self):
return f"{self.first_name}
{self.last_name} ({self.student_id})"
This code sets up a
structure for storing student details like their ID, name, date of birth,
email, phone number, and address in the database.