Django is a Python web framework for building websites with views, URL routes, templates, forms and database models. This guide links the lessons in a practical learning order, starting with a local project and progressing to MySQL-backed pages.
Quick start: create and run a local Django project
python -m pip install "Django>=5.2,<5.3"
django-admin startproject plus2net_demo
cd plus2net_demo
python manage.py runserver
Open http://127.0.0.1:8000/ after the server starts. Django includes a development server and uses SQLite by default, so MySQL is not required for the first lessons.
Begin with Django installation and your first project. That lesson explains virtual environments, manage.py, app creation, views, URLs, templates and the local server.
my_app/views.py
from django.http import HttpResponse
def index(request):
return HttpResponse("Hello from Django")
my_app/urls.py
from django.urls import path
from . import views
urlpatterns = [path("", views.index, name="home")]
After building a view, learn how to collect and validate data. Basic Django forms explains HTML forms, GET versus POST and CSRF tokens; Django form classes covers field-level validation, dropdowns, checkboxes and radio controls.
Read a query parameter in a view
from django.shortcuts import render
def welcome(request):
name = request.GET.get("name", "Guest")
return render(request, "welcome.html", {"name": name})
?id= and ?name= values and validate them before database use.{% for %} and {% empty %}.Build a common Student model in Django and MySQL. The same fields are used in each database lesson, so you can progress without repeatedly changing schema names. You may work with SQLite locally first.
students/models.py — common model across the database tutorials
from django.db import models
class Student(models.Model):
name = models.CharField(max_length=100)
cl = models.CharField(max_length=20, db_column="class")
mark = models.PositiveSmallIntegerField()
gender = models.CharField(max_length=20)
def __str__(self):
return self.name
ModelForm.bulk_create().all(), filter(), ordering and slicing.Representative project files; Django generates additional support files
plus2net_demo/
├── manage.py
├── plus2net_demo/
│ ├── settings.py
│ └── urls.py
└── students/
├── admin.py
├── apps.py
├── forms.py
├── models.py
├── urls.py
├── views.py
└── templates/students/
├── student_list.html
├── student_detail.html
└── student_form.html
These lessons use Django 5.2 LTS with supported Python versions, and focus on a coherent local example project with named URLs, templates and models. Review the official Django 5.2 documentation when applying examples to an existing project.
runserver command is for development, not production hosting. Never publish DEBUG=True, a real database password, or unprotected demonstration actions on a public server.| Step | Tutorial | What you learn |
|---|---|---|
| 1 | Install Django and create a project | Set up and run the framework |
| 2 | GET and POST forms | Build the next component of the same sample project |
| 3 | Form classes and validation | Build the next component of the same sample project |
| 4 | Query string parameters | Build the next component of the same sample project |
| 5 | Template for loops | Build the next component of the same sample project |
| 6 | CSS, JavaScript, jQuery and static files | Build the next component of the same sample project |
| 7 | MySQL connection and models | Build the next component of the same sample project |
| 8 | Insert form data | Build the next component of the same sample project |
| 9 | Insert multiple records | Build the next component of the same sample project |
| 10 | Display and filter MySQL rows | Build the next component of the same sample project |
| 11 | List and detail pages | Build the next component of the same sample project |
| 12 | Admin interface | Build the next component of the same sample project |
No. Django uses SQLite by default. Use SQLite for installation, templates and forms; switch to MySQL when you reach the database connection tutorial.
Start with installation, URLs, views and models first. The admin becomes more useful after a model exists.
No. Django is best learned as a local multi-file web project with its own development server. The tutorials provide copyable file-by-file examples rather than notebooks.
Next: Install Django and create a project
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.
28-12-2020 | |
| how to display only one record....can you tell me | |