Django Project Practical (Beginner)
TOPIC: Creating a Simple Registration Form (Name, Start Date, End Date, and Payment)
Learning Objectives
At the end of this lesson, students should be able to:
Create a Django model.
Create an HTML form.
Save data into a MySQL database.
View the saved data in the Django Admin Panel.
STEP 1: Create the Model
Open:
your_app/models.py
What we are doing
We are creating a database table called TrainingForm.
Each row will store:
Name
Start Date
End Date
Payment
Write:
from django.db import models
class TrainingForm(models.Model):
name = models.CharField(max_length=100)
start_date = models.DateField()
end_date = models.DateField()
payment = models.DecimalField(max_digits=10, decimal_places=2)
def __str__(self):
return self.name
Meaning of the Code
Line 1
from django.db import models
Imports Django's database tools.
Name
name = models.CharField(max_length=100)
Stores the student's name.
Example:
John David
Start Date
start_date = models.DateField()
Stores the date training begins.
Example:
2026-08-01
End Date
end_date = models.DateField()
Stores the date training ends.
Example:
2026-09-30
Payment
payment = models.DecimalField(max_digits=10, decimal_places=2)
Stores the payment amount.
Examples:
5000.00
15000.00
25000.50
STEP 2: Run Migration
What we are doing
We are creating the table inside MySQL.
Run:
python manage.py makemigrations
Then:
python manage.py migrate
STEP 3: Register the Model
Open:
your_app/admin.py
Write:
from django.contrib import admin
from .models import TrainingForm
admin.site.register(TrainingForm)
What we are doing
We are making the table visible in the Django Admin Panel.
STEP 4: Create the HTML Form
Create:
templates/register.html
Write:
<!DOCTYPE html>
<html>
<head>
<title>Training Registration</title>
</head>
<body>
<h2>Training Registration Form</h2>
<form method="POST">
{% csrf_token %}
<label>Name</label><br>
<input type="text" name="name" required><br><br>
<label>Start Date</label><br>
<input type="date" name="start_date" required><br><br>
<label>End Date</label><br>
<input type="date" name="end_date" required><br><br>
<label>Payment</label><br>
<input type="number" name="payment" step="0.01" required><br><br>
<button type="submit">Register</button>
</form>
</body>
</html>
What We Are Doing
We are creating a webpage where users can enter their information.
The form has:
Name
Start Date
End Date
Payment
Register button
STEP 5: Create the View
Open:
your_app/views.py
Write:
from django.shortcuts import render, redirect
from .models import TrainingForm
def register(request):
if request.method == "POST":
name = request.POST["name"]
start_date = request.POST["start_date"]
end_date = request.POST["end_date"]
payment = request.POST["payment"]
TrainingForm.objects.create(
name=name,
start_date=start_date,
end_date=end_date,
payment=payment,
)
return redirect("/")
return render(request, "register.html")
What We Are Doing
When the user clicks Register:
Django receives the form data.
Django creates a new record.
Django saves the record in MySQL.
The user is redirected to the home page.
STEP 6: Create the URL
Open:
your_app/urls.py
Write:
from django.urls import path
from . import views
urlpatterns = [
path("register/", views.register, name="register"),
]
STEP 7: Run the Server
python manage.py runserver
Open:
http://127.0.0.1:8000/register/
You should see a form like this:
-------------------------------------
Training Registration Form
Name
[_____________________]
Start Date
[ 2026-08-01 ]
End Date
[ 2026-09-30 ]
Payment
[__________]
[ Register ]
-------------------------------------
STEP 8: Check the Database
After submitting the form, log in to the Django Admin Panel:
http://127.0.0.1:8000/admin/
Click Training Forms to see the saved records.
Or check directly in MySQL:
USE your_database_name;
SELECT * FROM your_app_trainingform;
You should see data similar to:
| id | name | start_date | end_date | payment |
|---|---|---|---|---|
| 1 | John David | 2026-08-01 | 2026-09-30 | 15000.00 |
This is a complete beginner-friendly Django CRUD example that uses MySQL to store the submitted form data.

