Bird
Raised Fist0
Djangoframework~10 mins

Creating a Django project - Visual Walkthrough

Choose your learning style10 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.

Practice

(1/5)
1. What is the correct command to create a new Django project named mywebsite?
easy
A. django-admin startproject mywebsite
B. django startproject mywebsite
C. django-admin createproject mywebsite
D. django-admin newproject mywebsite

Solution

  1. Step 1: Understand the Django project creation command

    The official command to create a new Django project is django-admin startproject projectname.
  2. Step 2: Match the command with the project name

    Replacing projectname with mywebsite gives django-admin startproject mywebsite.
  3. Final Answer:

    django-admin startproject mywebsite -> Option A
  4. Quick Check:

    Correct command = django-admin startproject mywebsite [OK]
Hint: Use 'django-admin startproject' plus your project name [OK]
Common Mistakes:
  • Using 'django startproject' instead of 'django-admin startproject'
  • Using 'createproject' or 'newproject' which are invalid commands
  • Forgetting to specify the project name
2. Which of the following commands has the correct syntax to create a Django project called blog?
easy
A. django-admin startproject blog
B. django-admin start project blog
C. django-admin startprojectblog
D. django-admin create project blog

Solution

  1. Step 1: Check the command syntax

    The correct syntax is django-admin startproject projectname without spaces inside the command words.
  2. Step 2: Identify the correct option

    django-admin startproject blog matches the correct syntax exactly: django-admin startproject blog.
  3. Final Answer:

    django-admin startproject blog -> Option A
  4. Quick Check:

    Correct syntax = django-admin startproject blog [OK]
Hint: No spaces inside 'startproject', write as one word [OK]
Common Mistakes:
  • Adding spaces inside 'startproject' command
  • Combining command and project name without space
  • Using 'create' instead of 'startproject'
3. After running django-admin startproject testsite, which folder structure will be created?
medium
A. A folder named testsite with only one file settings.py
B. A folder named testsite containing only manage.py file
C. A folder named testsite containing manage.py and urls.py only
D. A folder named testsite containing manage.py and a subfolder testsite with settings files

Solution

  1. Step 1: Recall Django project folder structure

    Running django-admin startproject testsite creates a folder testsite with manage.py and a subfolder testsite containing settings.py, urls.py, asgi.py, and wsgi.py.
  2. Step 2: Match the correct folder structure

    A folder named testsite containing manage.py and a subfolder testsite with settings files correctly describes this structure with manage.py and a subfolder testsite holding settings files.
  3. Final Answer:

    Folder with manage.py and subfolder testsite with settings files -> Option D
  4. Quick Check:

    Default Django project structure = A folder named testsite containing manage.py and a subfolder testsite with settings files [OK]
Hint: Remember: project folder has manage.py plus inner folder with settings [OK]
Common Mistakes:
  • Expecting all files in one folder without subfolder
  • Thinking only manage.py is created
  • Confusing project folder and app folder structure
4. You ran django-admin startproject mysite but got an error: django-admin: command not found. What is the likely cause?
medium
A. You need to run the command inside an existing Django project folder
B. You typed the project name incorrectly
C. Django is not installed or not in your system PATH
D. The command should be django startproject mysite

Solution

  1. Step 1: Understand the error message

    The error django-admin: command not found means the system cannot find the django-admin command.
  2. Step 2: Identify the cause

    This usually happens if Django is not installed or the Python scripts folder is not in your system PATH environment variable.
  3. Final Answer:

    Django is not installed or not in your system PATH -> Option C
  4. Quick Check:

    Command not found = Django missing or PATH issue [OK]
Hint: Check Django installation and PATH if 'command not found' error appears [OK]
Common Mistakes:
  • Assuming project name typo causes command not found
  • Trying to run command inside project folder before creating it
  • Using wrong command syntax instead of fixing PATH
5. You want to create a Django project named shop inside a folder websites that already exists. Which is the correct way to do this?
hard
A. Run django-admin startproject websites/shop from any folder
B. Navigate to the websites folder in terminal, then run django-admin startproject shop
C. Create the shop folder manually inside websites then run django-admin startproject shop
D. Run django-admin startproject shop websites from the parent folder

Solution

  1. Step 1: Understand how startproject creates folders

    The startproject command creates a new folder with the project name in the current directory.
  2. Step 2: Choose the correct folder navigation

    To create shop inside websites, first go into websites folder, then run django-admin startproject shop.
  3. Final Answer:

    Navigate to websites folder, then run django-admin startproject shop -> Option B
  4. Quick Check:

    Run command inside target folder to create project there [OK]
Hint: Change directory to target folder before running startproject [OK]
Common Mistakes:
  • Trying to specify nested folder in startproject command
  • Creating folders manually before running startproject
  • Passing folder name as second argument to startproject
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard