Install Django inside a virtual environment, start a new project, add an application and connect a URL to a simple view. The example below uses a local development server and the Django 5.2 LTS release line.
Terminal: create a virtual environment, install Django, and run the server
python -m venv .venv
# Activate the environment before installing Django
python -m pip install "Django>=5.2,<5.3"
django-admin startproject plus2net_demo
cd plus2net_demo
python manage.py runserver
The Python executable used for python -m venv must be a supported version. On Windows activate with .venv\Scripts\activate; on macOS/Linux use source .venv/bin/activate. Start the server from the directory containing manage.py.
127.0.0.1:8000 address.Check Python, pip and installed Django versions
python --version
python -m pip --version
python -m django --version
Use a virtual environment to keep Django and package versions separate from other Python applications. The old virtualenvwrapper-win/mkvirtualenv commands are optional tools; Python’s built-in venv is sufficient for this tutorial.
Choose the one activation command that matches your operating system
# Windows Command Prompt
.venv\Scripts\activate.bat
# Windows PowerShell
.venv\Scripts\Activate.ps1
# macOS / Linux
source .venv/bin/activate
Run from the active virtual environment
django-admin startproject plus2net_demo
cd plus2net_demo
python manage.py startapp my_app
The project package contains settings.py, urls.py, asgi.py and wsgi.py. The new application contains views.py, models.py and other modules. The correct CLI command is django-admin with a hyphen, not django admin.
plus2net_demo/settings.py — add your app to the existing list
INSTALLED_APPS = [
"my_app",
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
]
my_app/views.py
from django.http import HttpResponse
def index(request):
return HttpResponse("Hello, welcome to Plus2Net Django")
my_app/urls.py — create this file
from django.urls import path
from . import views
urlpatterns = [
path("", views.index, name="home"),
]
plus2net_demo/urls.py
from django.contrib import admin
from django.urls import include, path
urlpatterns = [
path("admin/", admin.site.urls),
path("my_app/", include("my_app.urls")),
]
Navigate to http://127.0.0.1:8000/my_app/. The page should display the string returned from HttpResponse. This is the same view/URL routing workflow used by the forms and database lessons.
my_app/views.py — replace the earlier index function
from django.shortcuts import render
def index(request):
return render(request, "my_app/home.html", {"site": "Plus2Net"})
my_app/templates/my_app/home.html — create folders if needed
<!DOCTYPE html>
<html lang="en">
<head><meta charset="utf-8"><title>Django Home</title></head>
<body>
<h1>Welcome to {{ site }}</h1>
<p>This page is rendered from a Django template.</p>
</body>
</html>
With APP_DIRS=True in the default Django template engine configuration, app templates in a templates/ folder are discovered automatically. For a global template directory, configure TEMPLATES[0]["DIRS"] using BASE_DIR / "templates" rather than outdated os.path.join snippets.
Create default tables and an optional local admin user
python manage.py migrate
python manage.py createsuperuser
python manage.py runserver
The admin login URL is http://127.0.0.1:8000/admin/. To manage your own tables, first create a model, then follow Django admin or models and MySQL.
| File | Purpose |
|---|---|
manage.py | Run project commands such as migrate and runserver |
settings.py | Configure applications, templates, databases and security settings |
urls.py | Map browser paths to Django views |
views.py | Read requests and return responses |
models.py | Define database-backed data structures |
templates/ | Store server-rendered HTML pages |
python -m django or reinstall Django within the environment.python manage.py runserver 8001.INSTALLED_APPS.my_app.urls.Run the development server on port 8001
python manage.py runserver 8001
Then visit http://127.0.0.1:8001/my_app/. Changing the port does not change the URL routes inside your application.
Check configuration and model definitions
python manage.py check
List applied and unapplied migrations
python manage.py showmigrations
Built-in help for project commands
python manage.py help
Check the selected Python interpreter’s Django release
python -m django --version
Dot form: avoid a redundant outer project directory
mkdir my_workspace
cd my_workspace
django-admin startproject my_proj .
The trailing dot tells Django to create manage.py in the current directory rather than creating another outer project directory.
Modern pathlib form for template configuration
# settings.py — after the existing TEMPLATES definition
TEMPLATES[0]["DIRS"] = [BASE_DIR / "templates"]
TEMPLATES[0]["APP_DIRS"] = True
Create the templates directory alongside manage.py. Django still finds app-level templates because APP_DIRS remains true.
my_app/tests.py — test the earlier named URL
from django.test import SimpleTestCase
from django.urls import reverse
class HomePageTests(SimpleTestCase):
def test_home_page_returns_success(self):
response = self.client.get(reverse("home"))
self.assertEqual(response.status_code, 200)
Execute Django tests for installed applications
python manage.py test
Return to your system’s normal Python environment
deactivate
plus2net_demo as the main project name. The my_proj command is an explicitly marked alternative for a different folder layout.

Yes, Django 5.2 supports Python 3.11. Newer Django 6.x releases require newer Python versions. Follow the official version compatibility table.
No. A new Django project uses SQLite until you configure another database. MySQL is covered separately in the database lesson.
No. It is a development server. Production deployment requires appropriate settings, web server integration, secrets handling and HTTPS.
Previous: Django overview
Next: GET and POST forms
Browse the complete Django tutorial series.
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.