mysite#

What is mysite?#

mysite is the Django project directory that contains apps, the database, and a nested configuration package used by Django to run the project.

In project, mysite appears twice, and this is intentional.

Structure:

django_project/
β”œβ”€β”€ djenv/
└── mysite/          ← outer mysite (PROJECT ROOT)
   β”œβ”€β”€ myapp/
   β”œβ”€β”€ mysite/      ← inner mysite (DJANGO CONFIG)
   β”œβ”€β”€ db.sqlite3
   └── manage.py

Let’s break this down carefully.


1️⃣ Outer mysite/ (Project root)#

This folder is created when you run.

django-admin startproject mysite
This outer mysite/ is:
  • The Django project root

  • Where you run Django commands

  • NOT a Python package

  • NOT imported in code

It contains:
  • manage.py

  • apps (myapp)

  • database file

  • inner Django configuration folder


2️⃣ manage.py (command center)#

Location:

mysite/manage.py

This is the main control script for Django.

You use it for:

python manage.py runserver
python manage.py startapp myapp
python manage.py makemigrations
python manage.py migrate
python manage.py createsuperuser

Think of it as:

β€œThe remote control for your Django project”


3️⃣ db.sqlite3 (default database)#

Location:

mysite/db.sqlite3
  • Default database (SQLite)

  • Used for development and learning

  • Auto-created after first migration

In real projects:
  • Often replaced with PostgreSQL

  • Usually ignored in Git


4️⃣ myapp/ (Django app)#

Location:

mysite/myapp/
This is actual application code:
  • views

  • models

  • urls

  • admin

Django projects are collections of apps.


5️⃣ Inner mysite/ (Django configuration package)#

Location:

mysite/mysite/

This inner folder is the real Django configuration module.

It IS a Python package and contains:

mysite/mysite/
β”œβ”€β”€ __init__.py
β”œβ”€β”€ settings.py
β”œβ”€β”€ urls.py
β”œβ”€β”€ asgi.py
└── wsgi.py
This is where Django looks for:
  • settings

  • URL routing

  • deployment configuration


Why are there TWO mysite folders?#

This confuses almost everyone at first

Here’s the reason:

Folder

Purpose

outer mysite/

project workspace

inner mysite/

Django settings package

Django must have:
  • a project directory (workspace)

  • a Python package with settings

They often share the same name by default.

You can rename the outer one if you want β€” Django doesn’t care.


How Django uses mysite#

When you run:

python manage.py runserver
Django:
  1. Uses manage.py

  2. Loads settings from mysite.settings

  3. Reads URLs from mysite.urls

  4. Starts the server

That mysite.settings refers to the inner folder.


Analogy (very helpful)
  • 🏠 Outer mysite/ β†’ house

  • 🧠 Inner mysite/ β†’ brain

  • 🧱 myapp/ β†’ rooms

  • πŸ•Ή manage.py β†’ remote control


Common beginner mistakes
  • Editing files in the wrong mysite

  • Thinking outer mysite is imported

  • Deleting manage.py

  • Renaming inner mysite without updating settings

You avoided all of these