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:
Uses manage.py
Loads settings from mysite.settings
Reads URLs from mysite.urls
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