Creating Your First Django Project
In this page:
Creating a New Project
Running "django-admin startproject mysite" generates a new folder named "mysite" containing the initial Django project files, ready to run.
Example: Creating a New Project
Scaffolds a new Django project named mysite with the default file structure.
django-admin startproject mysite
⚠️ Run this command in your terminal.
Moving Into the Project Folder
After creation, you need to move into the outer project folder before running any other Django commands, since manage.py lives there.
Example: Moving Into the Project Folder
Changes into the newly created project directory.
cd mysite
⚠️ Run this command in your terminal.
Listing the Generated Files
Running "ls" inside the project folder shows manage.py and an inner settings package, confirming the project scaffold was created correctly.
Example: Listing the Generated Files
Lists the files and folders generated by startproject.
ls
⚠️ Run this command in your terminal.
What manage.py Does
manage.py is a command-line utility auto-generated with every project; it lets you run the server, apply migrations, and manage the app without typing long Python commands.
Example: What manage.py Does
Running manage.py help lists every subcommand it provides — runserver, migrate, createsuperuser, startapp, and more — confirming exactly what the file can do.
python manage.py help
⚠️ Run this command in your terminal.
- Running "django-admin startproject" with a name that matches an existing folder, causing conflicts.
- Forgetting the trailing dot when creating a project inside the current directory, which creates an unwanted extra nested folder.
- Not activating the virtual environment before running startproject, installing files with the wrong interpreter tracked.
- The "django-admin startproject" command scaffolds a new Django project.
- A project contains a settings.py, urls.py, and a manage.py entry point.
- manage.py is used to run project-specific commands like the dev server.
- The generated folder structure is the starting point for every Django app.
Chapter Quiz — Complete all 9 topics to unlock
0/9 topics done
Complete these topics first: