0
0
Djangoframework~10 mins

Creating a Django project - Visual Walkthrough

Choose your learning style9 modes available
Concept Flow - Creating a Django project
Open Terminal
Run: django-admin startproject myproject
Create myproject folder with files
Navigate into myproject folder
Run: python manage.py runserver
Server starts, project ready
This flow shows the steps to create a new Django project, from running the command to starting the server.
Execution Sample
Django
django-admin startproject myproject
cd myproject
python manage.py runserver
Creates a new Django project folder and starts the development server.
Execution Table
StepCommand RunActionResult
1django-admin startproject myprojectCreate project folder and filesFolder 'myproject' with manage.py and settings created
2cd myprojectChange directory to project folderTerminal now inside 'myproject' folder
3python manage.py runserverStart Django development serverServer runs at http://127.0.0.1:8000/
4Access http://127.0.0.1:8000/ in browserView default Django welcome pagePage shows 'The install worked successfully!'
5Stop server (Ctrl+C)Terminate server processServer stops running
💡 Server stops when user interrupts; project folder and files remain for development.
Variable Tracker
VariableStartAfter Step 1After Step 2After Step 3Final
Current DirectoryUser home or terminal startUser home or terminal start'myproject' folder'myproject' folder'myproject' folder
Project FolderNone'myproject' created'myproject' exists'myproject' exists'myproject' exists
Server StatusStoppedStoppedStoppedRunningStopped
Key Moments - 2 Insights
Why do we need to change directory into the project folder before running the server?
Because the 'manage.py' file that runs the server is inside the project folder. Running 'python manage.py runserver' outside won't work. See execution_table step 2 and 3.
What happens if you run 'django-admin startproject' with a folder name that already exists?
Django will raise an error because it does not want to overwrite existing files. You must choose a new folder name or delete the old one first.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the result after running 'django-admin startproject myproject'?
AServer starts running
BFolder 'myproject' with manage.py and settings created
CTerminal changes directory
DProject deleted
💡 Hint
Check the 'Result' column in step 1 of the execution_table.
At which step does the Django development server start running?
AStep 3
BStep 2
CStep 1
DStep 4
💡 Hint
Look at the 'Action' and 'Result' columns in the execution_table.
If you forget to change directory into 'myproject' before running the server, what will happen?
AServer will start normally
BA new project will be created
CTerminal will show an error because 'manage.py' is not found
DNothing happens
💡 Hint
Refer to key_moments about why changing directory is important.
Concept Snapshot
Creating a Django project:
1. Run 'django-admin startproject myproject' to create project folder.
2. Change directory into 'myproject' with 'cd myproject'.
3. Start server with 'python manage.py runserver'.
4. Access http://127.0.0.1:8000/ to see the welcome page.
Remember: Always run server inside project folder.
Full Transcript
To create a Django project, open your terminal and run the command 'django-admin startproject myproject'. This creates a new folder named 'myproject' with necessary files. Next, change your terminal directory into this folder using 'cd myproject'. Inside this folder, run 'python manage.py runserver' to start the development server. You can then open your browser and go to http://127.0.0.1:8000/ to see the default Django welcome page. When done, stop the server with Ctrl+C. Remember, running the server command outside the project folder will cause an error because the 'manage.py' file is not found there.