LinuxCommandLibrary

django-admin

Manage Django projects

TLDR

Create a new Django project

$ django-admin startproject [project_name]
copy

Create a new app for the current project
$ django-admin startapp [app_name]
copy

Display help for a specific command
$ django-admin help [command]
copy

Display version
$ django-admin --version
copy

SYNOPSIS

django-admin <subcommand> [options]

PARAMETERS

--verbosity=VERBOSE, -v VERBOSE
    Output verbosity level: 0=minimal output, 1=normal, 2=verbose, 3=very verbose

--settings=SETTINGS_MODULE
    Python path to settings module (e.g., myproject.settings)

--pythonpath=EXTRA_PATH, -p EXTRA_PATH
    Extra Python path(s) to prepend to sys.path

--traceback, -t
    Raise on command exceptions (print full traceback)

--no-color
    Don't colorize output

--force-color
    Force colorized output

--skip-checks
    Skip system checks

--database=DATABASE
    Database name to operate on (default: default)

--locale=LOCALE
    Locale for translations

--language=LANGUAGE
    Language code for translations

--help, -h
    Show help message and exit

--version
    Show program's version number and exit

DESCRIPTION

django-admin is the primary command-line interface for the Django Python web framework, enabling developers to manage projects efficiently. It handles tasks like creating new projects and apps, running development servers, database migrations, testing, and administrative operations. Installed via pip install Django, it operates globally but is often invoked through the project-specific manage.py wrapper for convenience.

Core workflows include scaffolding a project with startproject, adding apps via startapp, syncing databases with migrate, and serving locally using runserver. Options allow customization, such as setting verbosity, specifying settings modules, or enabling tracebacks for debugging. It's extensible, supporting custom management commands defined in Django apps. Ideal for rapid development, deployment preparation, and maintenance in production-like environments, it streamlines Django's batteries-included philosophy.

CAVEATS

Requires Django installed globally via pip. Use manage.py within projects for default settings. Some subcommands need a project directory or DJANGO_SETTINGS_MODULE environment variable. Not for production servers.

COMMON SUBCOMMANDS

startproject <projectname> [dir]
startapp <appname> [dir]
runserver [<host>:<port>]
migrate
makemigrations [<app_label>]
createsuperuser
test [<app_label>]

HISTORY

Developed alongside Django framework by Adrian Holovaty and Jacob Kaplan-Moss; first released in Django 0.96 (2007), stabilized in Django 1.0 (2008). Evolved with framework versions, adding subcommands for migrations (1.7+), checks (1.7+), and modern features.

SEE ALSO

manage.py(1), pip(1), python(1)

Copied to clipboard