Creating a Project

Use django-admin startproject to scaffold a new Django project.

Syntaxdjango-admin startproject <name> [directory]

Once Django is installed, the django-admin startproject command generates the skeleton of a new project: a settings package plus a manage.py script.

The name you pass becomes an inner configuration package. Many developers add a trailing . to avoid an extra nested folder.

Example

Example · bash
# Create a project called 'mysite' in the current folder
django-admin startproject mysite .

# Your tree now looks like:
#   manage.py
#   mysite/
#       __init__.py
#       settings.py
#       urls.py
#       asgi.py
#       wsgi.py

When to use it

  • A team bootstraps a new SaaS app by running django-admin startproject to get a working skeleton in seconds.
  • A developer creates a separate project directory for each client site, each with its own manage.py and settings.
  • A CI pipeline uses startproject to generate a fresh Django project for integration tests in an ephemeral container.

More examples

Create a new Django project

Generates the standard Django project skeleton and immediately starts the development server.

Example · bash
django-admin startproject mysite
cd mysite
python manage.py runserver

Place project at repo root

Using a dot avoids double-nesting and keeps manage.py at the repository root level.

Example · bash
mkdir mysite && cd mysite
django-admin startproject config .
# manage.py stays at root; settings live in config/

Apply initial migrations

Applies Django's built-in migrations and creates the first admin account after project creation.

Example · bash
cd mysite
python manage.py migrate
python manage.py createsuperuser

Discussion

  • Be the first to comment on this lesson.