Bird
Raised Fist0
Djangoframework~20 mins

Creating a Django project - Practice Exercises

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Django Project Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
📝 Syntax
intermediate
1:30remaining
What is the correct command to create a new Django project named 'myapp'?
Choose the command that correctly creates a new Django project called myapp.
Adjango-admin newproject myapp
Bdjango-admin createproject myapp
Cdjango-admin startproject myapp
Ddjango-admin initproject myapp
Attempts:
2 left
💡 Hint
The official Django command to start a project uses the word 'startproject'.
❓ component_behavior
intermediate
1:30remaining
What happens when you run 'python manage.py runserver' inside a Django project?
Select the correct description of what the command python manage.py runserver does inside a Django project directory.
ACompiles Django templates into static HTML files.
BStarts a local web server to serve the Django application for development.
CCreates a new Django app inside the project.
DDeploys the Django project to a live production server.
Attempts:
2 left
💡 Hint
Think about what you need to do to see your Django site in a browser during development.
🔧 Debug
advanced
2:00remaining
Why does this command fail? django-admin startproject myproject .
You run the command django-admin startproject myproject . inside an existing directory but get an error. What is the most likely cause?
AThe current directory is not empty, so Django refuses to create the project here.
BThe dot (.) at the end is invalid syntax for this command.
CYou must run the command outside any directory to create a project.
DThe project name cannot be 'myproject' because it conflicts with a Python module.
Attempts:
2 left
💡 Hint
Django expects an empty directory or a new directory for the project files.
❓ state_output
advanced
2:00remaining
After creating a Django project, what files are generated inside the project directory?
You run django-admin startproject mysite. Which of the following lists the files and folders you will find inside the mysite directory?
AAn apps folder with all Django apps pre-created
BOnly a manage.py file and a templates folder
CA single mysite.py file with all settings and URLs
Dmanage.py file and a subdirectory named mysite containing __init__.py, settings.py, urls.py, and wsgi.py
Attempts:
2 left
💡 Hint
Think about the default structure Django creates for a new project.
🧠 Conceptual
expert
2:30remaining
What is the purpose of the 'manage.py' file in a Django project?
Choose the best explanation of what the manage.py file does in a Django project.
AIt is a command-line utility that lets you interact with the Django project for tasks like running the server and migrations.
BIt compiles static files like CSS and JavaScript for deployment.
CIt stores the database configuration and credentials.
DIt contains the main application logic and routes HTTP requests.
Attempts:
2 left
💡 Hint
Think about how you run commands like 'runserver' or 'migrate' in Django.

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