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:

  1. Terminal open?

  2. In your project folder? (e.g. cd ~/django-learn-2026 or wherever you made it)

  3. Virtual environment activated? → You should see (venv) or similar in your prompt.

    Quick test:

    Bash

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):

Bash
  • 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:

Bash

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):

text
  • 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:

Bash

Or shorter (works the same):

Bash

You’ll see output like:

text

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:

  1. 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.
  2. mysite/settings.py (the brain of your project)

    Key sections you’ll change soon:

    Python

    Pro tip: Change TIME_ZONE right now to ‘Asia/Kolkata’ so dates/times feel natural.

  3. mysite/urls.py (your traffic cop)

    Default:

    Python

    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

Python

Now edit mysite/urls.py:

Python

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!

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *