0
0
Djangoframework~10 mins

Django project structure walkthrough - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - Django project structure walkthrough
Start: django-admin startproject
Create project folder
Create manage.py file
Create inner project folder
Create __init__.py
Create settings.py
Create urls.py
Create asgi.py & wsgi.py
Project ready for apps & runserver
This flow shows how Django creates the main project structure step-by-step when you start a new project.
Execution Sample
Django
django-admin startproject mysite
cd mysite
ls
Creates a new Django project folder named 'mysite' with the default files and folders inside.
Execution Table
StepActionCreated ItemDescription
1Run django-admin startproject mysitemysite/Main project folder created
2Inside mysite/, create manage.pymanage.pyCommand-line utility for project management
3Create inner mysite/ foldermysite/mysite/Contains project settings and config
4Create __init__.py inside inner mysite/__init__.pyMarks folder as Python package
5Create settings.py inside inner mysite/settings.pyProject configuration settings
6Create urls.py inside inner mysite/urls.pyURL routing for the project
7Create asgi.py and wsgi.py inside inner mysite/asgi.py, wsgi.pyEntry points for web servers
8Project structure readyAll files/foldersReady to add apps and run server
💡 All default files and folders created, project structure complete.
Variable Tracker
ItemBefore startprojectAfter step 1After step 2After step 3After step 7Final
mysite folderDoes not existExistsExistsExistsExistsExists
manage.pyDoes not existDoes not existExistsExistsExistsExists
mysite inner folderDoes not existDoes not existDoes not existExistsExistsExists
__init__.pyDoes not existDoes not existDoes not existExistsExistsExists
settings.pyDoes not existDoes not existDoes not existExistsExistsExists
urls.pyDoes not existDoes not existDoes not existExistsExistsExists
asgi.py & wsgi.pyDoes not existDoes not existDoes not existExistsExistsExists
Key Moments - 3 Insights
Why are there two folders named 'mysite' after creating the project?
The outer 'mysite' is the project container folder. The inner 'mysite' is a Python package holding settings and config files, as shown in steps 1 and 3 of the execution_table.
What is the purpose of manage.py?
manage.py is a command-line tool to interact with the project, like running the server or migrations. It is created in step 2 and is outside the inner project folder.
Why do we have __init__.py inside the inner folder?
__init__.py marks the inner folder as a Python package so Python can import settings and other modules. This is shown in step 4.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what file is created at step 5?
Asettings.py
Bmanage.py
Curls.py
D__init__.py
💡 Hint
Check the 'Created Item' column for step 5 in the execution_table.
At which step does the inner 'mysite' folder get created?
AStep 6
BStep 2
CStep 3
DStep 1
💡 Hint
Look for 'Create inner mysite/ folder' in the 'Action' column of the execution_table.
If manage.py was missing, which step likely failed?
AStep 1
BStep 2
CStep 3
DStep 4
💡 Hint
manage.py is created in step 2 according to the execution_table.
Concept Snapshot
Django project structure:
- Outer folder: project container
- manage.py: command tool
- Inner folder: Python package
- settings.py: config
- urls.py: routing
- asgi.py/wsgi.py: server entry
Created by django-admin startproject
Full Transcript
When you run 'django-admin startproject mysite', Django creates a main folder named 'mysite'. Inside it, there is a manage.py file for commands. Also, an inner folder named 'mysite' is created, which is a Python package containing __init__.py, settings.py, urls.py, asgi.py, and wsgi.py. These files configure the project, handle URL routing, and provide server interfaces. This structure is ready for adding apps and running the development server.