django-admin
Manage Django projects
TLDR
Create a new Django project
Create a new app for the current project
Check the current version of Django
Display help for a specific command
SYNOPSIS
django-admin subcommand [options]
PARAMETERS
startproject <project_name>
Creates a new Django project named <project_name>
.startapp <app_name>
Creates a new Django app named <app_name>
within your project.runserver [port_number]
Starts the Django development server.
Defaults to port 8000 if no port_number
is specified.migrate
Applies pending database migrations.makemigrations [app_label]
Creates new migrations based on changes to your models.
Optionally specify the app_label
.createsuperuser
Creates a superuser account for accessing the Django admin interface.shell
Opens the Django shell with the project's settings loaded.dbshell
Opens the database client corresponding to the database specified in your settings.showmigrations
Lists all migrations and their status.check
Checks the Django project for any potential problems.--settings=module
Specifies the settings module to use.
Overrides the DJANGO_SETTINGS_MODULE
environment variable.--pythonpath=directory
Adds a directory to the Python import search path.--traceback
Show full traceback on exception.--version
Show program's version number and exit.--help
Show this help message and exit.
DESCRIPTION
The django-admin
command is Django's command-line utility for administrative tasks.
It's used for a variety of things like creating projects, managing databases, running the development server, and more. It's a powerful tool for Django developers, providing a consistent interface for interacting with Django projects.
django-admin
primarily operates on Django projects. It provides subcommands to facilitate actions such as project creation, application management, and database administration. You must configure the DJANGO_SETTINGS_MODULE
environment variable if your project isn't in the current path. This ensures that django-admin knows which settings file to use. Without settings configured, some commands may not operate correctly.
This is a crucial utility for managing a Django project lifecycle.
CAVEATS
Ensure the DJANGO_SETTINGS_MODULE
environment variable is set correctly, or use the --settings
option to specify the settings file.
<I>CUSTOM COMMANDS</I>
You can extend django-admin by creating your own custom management commands within your Django apps. Place custom command files in a management/commands directory inside your application directory.
<I>ENVIRONMENT VARIABLES</I>
The most important environment variable is DJANGO_SETTINGS_MODULE
, which tells Django where your project's settings file is located.