Chapter 6: Django Create Project
Django version we’re using: 6.0.1 (stable as of today, patch release from Jan 6, 2026 — safe, modern, supports Python 3.12–3.14)
Prerequisites Check (30-second sanity check)
Before we type anything:
-
Terminal open?
-
In your project folder? (e.g. cd ~/django-learn-2026 or wherever you made it)
-
Virtual environment activated? → You should see (venv) or similar in your prompt.
Quick test:
Bash01234567python -m django --version# Should say: 6.0.1
If not → go back to previous steps (activate venv, reinstall Django if needed).
Step 1: The One Command That Creates Everything
Run this exactly (pay attention to the dot at the end):
|
0 1 2 3 4 5 6 |
django-admin startproject mysite . |
- django-admin → the command-line tool that came with Django
- startproject → tells it “create a new Django project”
- mysite → the name of your project (you can choose anything: myblog, todoapp, webliance, etc. — lowercase + no spaces/hyphens usually best)
- . (the dot!) → super important! It means “create it right here in the current folder” instead of making a new nested folder.
Without the dot it would do:
|
0 1 2 3 4 5 6 7 |
django-admin startproject mysite # Creates mysite/ folder containing another mysite/ → nested mess |
Most beginners forget the dot the first time — then wonder why everything is double-nested. Easy fix: just delete the extra folder and rerun with dot.
What Happens After Running It? (Folder Structure Revealed)
Your current folder now looks like this (clean & standard):
|
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
django-learn-2026/ ← your outer folder (you chose the name) ├── manage.py ← your project's "remote control" script ├── mysite/ ← the actual project package │ ├── __init__.py ← makes this folder a Python package │ ├── asgi.py ← for async servers (modern Django, ASGI) │ ├── settings.py ← ALL configuration: DB, apps, time zone, etc. │ ├── urls.py ← main URL routing table │ └── wsgi.py ← for traditional web servers (WSGI) └── venv/ ← your virtual env (ignore this) |
- manage.py is special — you run almost all Django commands through it (like python manage.py runserver)
- The inner mysite/ folder is named after your project — it’s a Python module/package.
Common naming tip: Many people name the outer folder something descriptive (polls-project, blog-2026) and the inner project core or config — but for first project, mysite is fine (official tutorial uses it).
Step 2: Run the Development Server (Magic Moment!)
Still in the same folder:
|
0 1 2 3 4 5 6 |
python manage.py runserver |
Or shorter (works the same):
|
0 1 2 3 4 5 6 |
python manage.py runserver |
You’ll see output like:
|
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
Watching for file changes with StatReloader Performing system checks... System check identified no issues (0 silenced). You have 18 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions. Run 'python manage.py migrate' to apply them. January 31, 2026 - 15:45:12 Django version 6.0.1, using settings 'mysite.settings' Starting development server at http://127.0.0.1:8000/ Quit the server with CONTROL-C. |
Open your browser → http://127.0.0.1:8000/ (or http://localhost:8000/)
You should see:
The install worked successfully! Congratulations!
Big rocket 🚀, Django logo, “It worked!” message — this is Django’s default welcome page when no root URL is defined yet.
Success! You’ve created and launched your first Django project.
Press Ctrl + C in terminal to stop the server.
Step 3: Quick Tour – What’s Inside the Important Files?
Open the folder in VS Code (or your editor) and let’s peek:
-
manage.py (don’t edit this — it’s auto-generated)
- Think of it as npm run or ./gradlew — entry point for commands
- Example uses: python manage.py startapp blog, python manage.py makemigrations, etc.
-
mysite/settings.py (the brain of your project)
Key sections you’ll change soon:
Python012345678910INSTALLED_APPS = [ ... ] # add your apps here laterTIME_ZONE = 'Asia/Kolkata' # Change from 'UTC' to your local (Hyderabad!)LANGUAGE_CODE = 'en-us' # or 'te' for Telugu if you wantALLOWED_HOSTS = [] # later add 'localhost', your domainDATABASES = { ... } # default is SQLite — perfect for learningPro tip: Change TIME_ZONE right now to ‘Asia/Kolkata’ so dates/times feel natural.
-
mysite/urls.py (your traffic cop)
Default:
Python01234567891011from django.contrib import adminfrom django.urls import pathurlpatterns = [path("admin/", admin.site.urls),]This says: only /admin/ route exists right now → that’s why root / shows the welcome page.
Step 4: Small First Customization (Make It Yours)
Let’s prove it’s working by adding a simple root page.
Create a new file: mysite/views.py
|
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
from django.http import HttpResponse def home(request): return HttpResponse(""" <h1 style="color: #006400; text-align: center; margin-top: 120px;"> నమస్తే Webliance! Your first Django project is LIVE! 🚀 </h1> <p style="text-align: center; font-size: 1.4rem; color: #2f4f4f;"> Created on January 31, 2026 in Hyderabad </p> """) |
Now edit mysite/urls.py:
|
0 1 2 3 4 5 6 7 8 9 10 11 12 13 |
from django.contrib import admin from django.urls import path from .views import home # ← import the view we just made urlpatterns = [ path('admin/', admin.site.urls), path('', home, name='home'), # ← '' means root URL / ] |
Restart server (python manage.py runserver)
Refresh browser → your custom message in green!
Common “Oh No” Moments & Fixes
- “CommandError: You must set settings.ALLOWED_HOSTS if DEBUG is False” → won’t happen yet (DEBUG=True by default)
- Server says “port 8000 in use” → python manage.py runserver 8001 or kill old process
- No rocket page? Just blank or 404? → check if you forgot the dot in startproject → wrong folder structure
- ImportError: cannot import name ‘home’ → typo in urls.py or views.py not saved
Homework / Next Steps
You’ve now:
- Created a project
- Understood the structure
- Run the dev server
- Made a tiny custom view
Tell me what you want next:
- “Let’s create our first app (like polls or todo)”
- “Show me how to use the admin panel (create superuser)”
- “Explain settings.py in detail (time zone, installed apps, etc.)”
- “I got this error — help!” (paste it)
- Or “Add templates instead of raw HTML”
You’re doing awesome — one more step and you’ll be building real stuff! 💻🇮🇳 Let’s go!
