1
0
mirror of https://github.com/django/django.git synced 2025-05-18 12:56:29 +00:00

[5.2.x] Updated man page for Django 5.2 final.

This commit is contained in:
Sarah Boyce 2025-04-02 14:47:20 +02:00
parent 9c6f8feaeb
commit 34bc3a3f88

View File

@ -27,23 +27,23 @@ level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
.in \\n[rst2man-indent\\n[rst2man-indent-level]]u .in \\n[rst2man-indent\\n[rst2man-indent-level]]u
.. ..
.TH "DJANGO-ADMIN" "1" "March 19, 2025" "5.2" "Django" .TH "DJANGO-ADMIN" "1" "April 02, 2025" "5.2" "Django"
.SH NAME .SH NAME
django-admin \- Utility script for the Django web framework django-admin \- Utility script for the Django web framework
.sp .sp
\fBdjango\-admin\fP is Djangos command\-line utility for administrative tasks. \fBdjango\-admin\fP is Django\(aqs command\-line utility for administrative tasks.
This document outlines all it can do. This document outlines all it can do.
.sp .sp
In addition, \fBmanage.py\fP is automatically created in each Django project. It In addition, \fBmanage.py\fP is automatically created in each Django project. It
does the same thing as \fBdjango\-admin\fP but also sets the does the same thing as \fBdjango\-admin\fP but also sets the
\fI\%DJANGO_SETTINGS_MODULE\fP environment variable so that it points to your \fI\%DJANGO_SETTINGS_MODULE\fP environment variable so that it points to your
projects \fBsettings.py\fP file. project\(aqs \fBsettings.py\fP file.
.sp .sp
The \fBdjango\-admin\fP script should be on your system path if you installed The \fBdjango\-admin\fP script should be on your system path if you installed
Django via \fBpip\fP\&. If its not in your path, ensure you have your virtual Django via \fBpip\fP\&. If it\(aqs not in your path, ensure you have your virtual
environment activated. environment activated.
.sp .sp
Generally, when working on a single Django project, its easier to use Generally, when working on a single Django project, it\(aqs easier to use
\fBmanage.py\fP than \fBdjango\-admin\fP\&. If you need to switch between multiple \fBmanage.py\fP than \fBdjango\-admin\fP\&. If you need to switch between multiple
Django settings files, use \fBdjango\-admin\fP with Django settings files, use \fBdjango\-admin\fP with
\fI\%DJANGO_SETTINGS_MODULE\fP or the \fI\%\-\-settings\fP command line \fI\%DJANGO_SETTINGS_MODULE\fP or the \fI\%\-\-settings\fP command line
@ -83,7 +83,7 @@ Run \fBdjango\-admin help <command>\fP to display a description of the given
command and a list of its available options. command and a list of its available options.
.SS App names .SS App names
.sp .sp
Many commands take a list of “app names.” An “app name” is the basename of Many commands take a list of \(dqapp names.\(dq An \(dqapp name\(dq is the basename of
the package containing your models. For example, if your \fI\%INSTALLED_APPS\fP the package containing your models. For example, if your \fI\%INSTALLED_APPS\fP
contains the string \fB\(aqmysite.blog\(aq\fP, the app name is \fBblog\fP\&. contains the string \fB\(aqmysite.blog\(aq\fP, the app name is \fBblog\fP\&.
.SS Determining the version .SS Determining the version
@ -267,7 +267,7 @@ django\-admin compilemessages \-\-ignore=cache \-\-ignore=outdated/*/locale
.UNINDENT .UNINDENT
.sp .sp
Creates the cache tables for use with the database cache backend using the Creates the cache tables for use with the database cache backend using the
information from your settings file. See \fI\%Djangos cache framework\fP for more information from your settings file. See \fI\%Django\(aqs cache framework\fP for more
information. information.
.INDENT 0.0 .INDENT 0.0
.TP .TP
@ -305,7 +305,7 @@ For Oracle, this runs the \fBsqlplus\fP command\-line client.
.sp .sp
This command assumes the programs are on your \fBPATH\fP so that a call to This command assumes the programs are on your \fBPATH\fP so that a call to
the program name (\fBpsql\fP, \fBmysql\fP, \fBsqlite3\fP, \fBsqlplus\fP) will find the the program name (\fBpsql\fP, \fBmysql\fP, \fBsqlite3\fP, \fBsqlplus\fP) will find the
program in the right place. Theres no way to specify the location of the program in the right place. There\(aqs no way to specify the location of the
program manually. program manually.
.INDENT 0.0 .INDENT 0.0
.TP .TP
@ -320,7 +320,7 @@ Specifies the database onto which to open a shell. Defaults to \fBdefault\fP\&.
.sp .sp
Any arguments following a \fB\-\-\fP divider will be passed on to the underlying Any arguments following a \fB\-\-\fP divider will be passed on to the underlying
command\-line client. For example, with PostgreSQL you can use the \fBpsql\fP command\-line client. For example, with PostgreSQL you can use the \fBpsql\fP
commands \fB\-c\fP flag to execute a raw SQL query directly: command\(aqs \fB\-c\fP flag to execute a raw SQL query directly:
.INDENT 0.0 .INDENT 0.0
.INDENT 3.5 .INDENT 3.5
.sp .sp
@ -334,7 +334,7 @@ $ django\-admin dbshell \-\- \-c \(aqselect current_user\(aq
.UNINDENT .UNINDENT
.UNINDENT .UNINDENT
.sp .sp
On MySQL/MariaDB, you can do this with the \fBmysql\fP commands \fB\-e\fP flag: On MySQL/MariaDB, you can do this with the \fBmysql\fP command\(aqs \fB\-e\fP flag:
.INDENT 0.0 .INDENT 0.0
.INDENT 3.5 .INDENT 3.5
.sp .sp
@ -363,11 +363,11 @@ command\-line client, e.g. \fB\(aqisolation_level\(aq\fP\&.
.B django\-admin diffsettings .B django\-admin diffsettings
.UNINDENT .UNINDENT
.sp .sp
Displays differences between the current settings file and Djangos default Displays differences between the current settings file and Django\(aqs default
settings (or another settings file specified by \fI\%\-\-default\fP). settings (or another settings file specified by \fI\%\-\-default\fP).
.sp .sp
Settings that dont appear in the defaults are followed by \fB\(dq###\(dq\fP\&. For Settings that don\(aqt appear in the defaults are followed by \fB\(dq###\(dq\fP\&. For
example, the default settings dont define \fI\%ROOT_URLCONF\fP, so example, the default settings don\(aqt define \fI\%ROOT_URLCONF\fP, so
\fI\%ROOT_URLCONF\fP is followed by \fB\(dq###\(dq\fP in the output of \fI\%ROOT_URLCONF\fP is followed by \fB\(dq###\(dq\fP in the output of
\fBdiffsettings\fP\&. \fBdiffsettings\fP\&.
.INDENT 0.0 .INDENT 0.0
@ -375,7 +375,7 @@ example, the default settings dont define \fI\%ROOT_URLCONF\fP, so
.B \-\-all .B \-\-all
.UNINDENT .UNINDENT
.sp .sp
Displays all settings, even if they have Djangos default value. Such settings Displays all settings, even if they have Django\(aqs default value. Such settings
are prefixed by \fB\(dq###\(dq\fP\&. are prefixed by \fB\(dq###\(dq\fP\&.
.INDENT 0.0 .INDENT 0.0
.TP .TP
@ -383,14 +383,14 @@ are prefixed by \fB\(dq###\(dq\fP\&.
.UNINDENT .UNINDENT
.sp .sp
The settings module to compare the current settings against. Leave empty to The settings module to compare the current settings against. Leave empty to
compare against Djangos default settings. compare against Django\(aqs default settings.
.INDENT 0.0 .INDENT 0.0
.TP .TP
.B \-\-output {hash,unified} .B \-\-output {hash,unified}
.UNINDENT .UNINDENT
.sp .sp
Specifies the output format. Available values are \fBhash\fP and \fBunified\fP\&. Specifies the output format. Available values are \fBhash\fP and \fBunified\fP\&.
\fBhash\fP is the default mode that displays the output thats described above. \fBhash\fP is the default mode that displays the output that\(aqs described above.
\fBunified\fP displays the output similar to \fBdiff \-u\fP\&. Default settings are \fBunified\fP displays the output similar to \fBdiff \-u\fP\&. Default settings are
prefixed with a minus sign, followed by the changed setting prefixed with a prefixed with a minus sign, followed by the changed setting prefixed with a
plus sign. plus sign.
@ -413,7 +413,7 @@ When result of \fBdumpdata\fP is saved as a file, it can serve as a
\fI\%initial data\fP\&. \fI\%initial data\fP\&.
.sp .sp
Note that \fBdumpdata\fP uses the default manager on the model for selecting the Note that \fBdumpdata\fP uses the default manager on the model for selecting the
records to dump. If youre using a \fI\%custom manager\fP as records to dump. If you\(aqre using a \fI\%custom manager\fP as
the default manager and it filters some of the available records, not all of the the default manager and it filters some of the available records, not all of the
objects will be dumped. objects will be dumped.
.INDENT 0.0 .INDENT 0.0
@ -421,7 +421,7 @@ objects will be dumped.
.B \-\-all, \-a .B \-\-all, \-a
.UNINDENT .UNINDENT
.sp .sp
Uses Djangos base manager, dumping records which might otherwise be filtered Uses Django\(aqs base manager, dumping records which might otherwise be filtered
or modified by a custom manager. or modified by a custom manager.
.INDENT 0.0 .INDENT 0.0
.TP .TP
@ -470,7 +470,7 @@ Specifies the database from which data will be dumped. Defaults to \fBdefault\fP
.sp .sp
Uses the \fBnatural_key()\fP model method to serialize any foreign key and Uses the \fBnatural_key()\fP model method to serialize any foreign key and
many\-to\-many relationship to objects of the type that defines the method. If many\-to\-many relationship to objects of the type that defines the method. If
youre dumping \fBcontrib.auth\fP \fBPermission\fP objects or you\(aqre dumping \fBcontrib.auth\fP \fBPermission\fP objects or
\fBcontrib.contenttypes\fP \fBContentType\fP objects, you should probably use this \fBcontrib.contenttypes\fP \fBContentType\fP objects, you should probably use this
flag. See the \fI\%natural keys\fP flag. See the \fI\%natural keys\fP
documentation for more details on this and the next option. documentation for more details on this and the next option.
@ -550,7 +550,7 @@ arguments. If no arguments are provided, models are created for views only if
the \fI\%\-\-include\-views\fP option is used. Models for partition tables are the \fI\%\-\-include\-views\fP option is used. Models for partition tables are
created on PostgreSQL if the \fI\%\-\-include\-partitions\fP option is used. created on PostgreSQL if the \fI\%\-\-include\-partitions\fP option is used.
.sp .sp
Use this if you have a legacy database with which youd like to use Django. Use this if you have a legacy database with which you\(aqd like to use Django.
The script will inspect the database and create a model for each table within The script will inspect the database and create a model for each table within
it. it.
.sp .sp
@ -559,7 +559,7 @@ in the table. Note that \fBinspectdb\fP has a few special cases in its field\-na
output: output:
.INDENT 0.0 .INDENT 0.0
.IP \(bu 2 .IP \(bu 2
If \fBinspectdb\fP cannot map a columns type to a model field type, itll If \fBinspectdb\fP cannot map a column\(aqs type to a model field type, it\(aqll
use \fBTextField\fP and will insert the Python comment use \fBTextField\fP and will insert the Python comment
\fB\(aqThis field type is a guess.\(aq\fP next to the field in the generated \fB\(aqThis field type is a guess.\(aq\fP next to the field in the generated
model. The recognized fields may depend on apps listed in model. The recognized fields may depend on apps listed in
@ -577,19 +577,19 @@ field.
.UNINDENT .UNINDENT
.sp .sp
This feature is meant as a shortcut, not as definitive model generation. After This feature is meant as a shortcut, not as definitive model generation. After
you run it, youll want to look over the generated models yourself to make you run it, you\(aqll want to look over the generated models yourself to make
customizations. In particular, youll need to rearrange models order, so that customizations. In particular, you\(aqll need to rearrange models\(aq order, so that
models that refer to other models are ordered properly. models that refer to other models are ordered properly.
.sp .sp
Django doesnt create database defaults when a Django doesn\(aqt create database defaults when a
\fI\%default\fP is specified on a model field. \fI\%default\fP is specified on a model field.
Similarly, database defaults arent translated to model field defaults or Similarly, database defaults aren\(aqt translated to model field defaults or
detected in any fashion by \fBinspectdb\fP\&. detected in any fashion by \fBinspectdb\fP\&.
.sp .sp
By default, \fBinspectdb\fP creates unmanaged models. That is, \fBmanaged = False\fP By default, \fBinspectdb\fP creates unmanaged models. That is, \fBmanaged = False\fP
in the models \fBMeta\fP class tells Django not to manage each tables creation, in the model\(aqs \fBMeta\fP class tells Django not to manage each table\(aqs creation,
modification, and deletion. If you do want to allow Django to manage the modification, and deletion. If you do want to allow Django to manage the
tables lifecycle, youll need to change the table\(aqs lifecycle, you\(aqll need to change the
\fI\%managed\fP option to \fBTrue\fP (or remove \fI\%managed\fP option to \fBTrue\fP (or remove
it because \fBTrue\fP is its default value). it because \fBTrue\fP is its default value).
.SS Database\-specific notes .SS Database\-specific notes
@ -722,8 +722,8 @@ directory. After making changes to the messages files you need to compile them
with \fI\%compilemessages\fP for use with the builtin gettext support. See with \fI\%compilemessages\fP for use with the builtin gettext support. See
the \fI\%i18n documentation\fP for details. the \fI\%i18n documentation\fP for details.
.sp .sp
This command doesnt require configured settings. However, when settings arent This command doesn\(aqt require configured settings. However, when settings aren\(aqt
configured, the command cant ignore the \fI\%MEDIA_ROOT\fP and configured, the command can\(aqt ignore the \fI\%MEDIA_ROOT\fP and
\fI\%STATIC_ROOT\fP directories or include \fI\%LOCALE_PATHS\fP\&. \fI\%STATIC_ROOT\fP directories or include \fI\%LOCALE_PATHS\fP\&.
.INDENT 0.0 .INDENT 0.0
.TP .TP
@ -853,9 +853,9 @@ Disables breaking long message lines into several lines in language files.
.B \-\-no\-location .B \-\-no\-location
.UNINDENT .UNINDENT
.sp .sp
Suppresses writing \fB#: filename:line\fP comment lines in language files. Suppresses writing \(aq\fB#: filename:line\fP comment lines in language files.
Using this option makes it harder for technically skilled translators to Using this option makes it harder for technically skilled translators to
understand each messages context. understand each message\(aqs context.
.INDENT 0.0 .INDENT 0.0
.TP .TP
.B \-\-add\-location [{full,file,never}] .B \-\-add\-location [{full,file,never}]
@ -910,8 +910,8 @@ Providing one or more app names as arguments will limit the migrations created
to the app(s) specified and any dependencies needed (the table at the other end to the app(s) specified and any dependencies needed (the table at the other end
of a \fBForeignKey\fP, for example). of a \fBForeignKey\fP, for example).
.sp .sp
To add migrations to an app that doesnt have a \fBmigrations\fP directory, run To add migrations to an app that doesn\(aqt have a \fBmigrations\fP directory, run
\fBmakemigrations\fP with the apps \fBapp_label\fP\&. \fBmakemigrations\fP with the app\(aqs \fBapp_label\fP\&.
.INDENT 0.0 .INDENT 0.0
.TP .TP
.B \-\-noinput, \-\-no\-input .B \-\-noinput, \-\-no\-input
@ -995,14 +995,14 @@ The behavior of this command changes depending on the arguments provided:
No arguments: All apps have all of their migrations run. No arguments: All apps have all of their migrations run.
.IP \(bu 2 .IP \(bu 2
\fB<app_label>\fP: The specified app has its migrations run, up to the most \fB<app_label>\fP: The specified app has its migrations run, up to the most
recent migration. This may involve running other apps migrations too, due recent migration. This may involve running other apps\(aq migrations too, due
to dependencies. to dependencies.
.IP \(bu 2 .IP \(bu 2
\fB<app_label> <migrationname>\fP: Brings the database schema to a state where \fB<app_label> <migrationname>\fP: Brings the database schema to a state where
the named migration is applied, but no later migrations in the same app are the named migration is applied, but no later migrations in the same app are
applied. This may involve unapplying migrations if you have previously applied. This may involve unapplying migrations if you have previously
migrated past the named migration. You can use a prefix of the migration migrated past the named migration. You can use a prefix of the migration
name, e.g. \fB0001\fP, as long as its unique for the given app name. Use the name, e.g. \fB0001\fP, as long as it\(aqs unique for the given app name. Use the
name \fBzero\fP to migrate all the way back i.e. to revert all applied name \fBzero\fP to migrate all the way back i.e. to revert all applied
migrations for an app. migrations for an app.
.UNINDENT .UNINDENT
@ -1030,7 +1030,7 @@ Marks the migrations up to the target one (following the rules above) as
applied, but without actually running the SQL to change your database schema. applied, but without actually running the SQL to change your database schema.
.sp .sp
This is intended for advanced users to manipulate the This is intended for advanced users to manipulate the
current migration state directly if theyre manually applying changes; current migration state directly if they\(aqre manually applying changes;
be warned that using \fB\-\-fake\fP runs the risk of putting the migration state be warned that using \fB\-\-fake\fP runs the risk of putting the migration state
table into a state where manual recovery will be needed to make migrations table into a state where manual recovery will be needed to make migrations
run correctly. run correctly.
@ -1039,7 +1039,7 @@ run correctly.
.B \-\-fake\-initial .B \-\-fake\-initial
.UNINDENT .UNINDENT
.sp .sp
Allows Django to skip an apps initial migration if all database tables with Allows Django to skip an app\(aqs initial migration if all database tables with
the names of all models created by all the names of all models created by all
\fI\%CreateModel\fP operations in that \fI\%CreateModel\fP operations in that
migration already exist. This option is intended for use when first running migration already exist. This option is intended for use when first running
@ -1059,7 +1059,7 @@ command.
.B \-\-run\-syncdb .B \-\-run\-syncdb
.UNINDENT .UNINDENT
.sp .sp
Allows creating tables for apps without migrations. While this isnt Allows creating tables for apps without migrations. While this isn\(aqt
recommended, the migrations framework is sometimes too slow on large projects recommended, the migrations framework is sometimes too slow on large projects
with hundreds of models. with hundreds of models.
.INDENT 0.0 .INDENT 0.0
@ -1130,11 +1130,11 @@ able to handle a production environment is outside the scope of Django.
.UNINDENT .UNINDENT
.sp .sp
The development server automatically reloads Python code for each request, as The development server automatically reloads Python code for each request, as
needed. You dont need to restart the server for code changes to take effect. needed. You don\(aqt need to restart the server for code changes to take effect.
However, some actions like adding files dont trigger a restart, so youll However, some actions like adding files don\(aqt trigger a restart, so you\(aqll
have to restart the server in these cases. have to restart the server in these cases.
.sp .sp
If youre using Linux or MacOS and install both \X'tty: link https://pypi.org/project/pywatchman/'\fI\%pywatchman\fP\X'tty: link' and the If you\(aqre using Linux or MacOS and install both \X'tty: link https://pypi.org/project/pywatchman/'\fI\%pywatchman\fP\X'tty: link' and the
\X'tty: link https://facebook.github.io/watchman/'\fI\%Watchman\fP\X'tty: link' service, kernel signals will be used to autoreload the server \X'tty: link https://facebook.github.io/watchman/'\fI\%Watchman\fP\X'tty: link' service, kernel signals will be used to autoreload the server
(rather than polling file modification timestamps each second). This offers (rather than polling file modification timestamps each second). This offers
better performance on large projects, reduced response time after code changes, better performance on large projects, reduced response time after code changes,
@ -1145,7 +1145,7 @@ more robust change detection, and a reduction in power usage. Django supports
.IP "Large directories with many files may cause performance issues" .IP "Large directories with many files may cause performance issues"
.sp .sp
When using Watchman with a project that includes large non\-Python When using Watchman with a project that includes large non\-Python
directories like \fBnode_modules\fP, its advisable to ignore this directory directories like \fBnode_modules\fP, it\(aqs advisable to ignore this directory
for optimal performance. See the \X'tty: link https://facebook.github.io/watchman/docs/config#ignore_dirs'\fI\%watchman documentation\fP\X'tty: link' for information for optimal performance. See the \X'tty: link https://facebook.github.io/watchman/docs/config#ignore_dirs'\fI\%watchman documentation\fP\X'tty: link' for information
on how to do this. on how to do this.
.UNINDENT .UNINDENT
@ -1169,7 +1169,7 @@ project for some common errors (see the \fI\%check\fP command). If any
errors are found, they will be printed to standard output. You can use the errors are found, they will be printed to standard output. You can use the
\fB\-\-skip\-checks\fP option to skip running system checks. \fB\-\-skip\-checks\fP option to skip running system checks.
.sp .sp
You can run as many concurrent servers as you want, as long as theyre on You can run as many concurrent servers as you want, as long as they\(aqre on
separate ports by executing \fBdjango\-admin runserver\fP more than once. separate ports by executing \fBdjango\-admin runserver\fP more than once.
.sp .sp
Note that the default IP address, \fB127.0.0.1\fP, is not accessible from other Note that the default IP address, \fB127.0.0.1\fP, is not accessible from other
@ -1212,7 +1212,7 @@ Uses IPv6 for the development server. This changes the default IP address from
\fB127.0.0.1\fP to \fB::1\fP\&. \fB127.0.0.1\fP to \fB::1\fP\&.
.INDENT 0.0 .INDENT 0.0
.TP .TP
.B HIDE_PRODUCTION_WARNING .B DJANGO_RUNSERVER_HIDE_WARNING
.UNINDENT .UNINDENT
.sp .sp
@ -1323,13 +1323,13 @@ django\-admin runserver \-6 localhost:8000
.UNINDENT .UNINDENT
.SS Serving static files with the development server .SS Serving static files with the development server
.sp .sp
By default, the development server doesnt serve any static files for your site By default, the development server doesn\(aqt serve any static files for your site
(such as CSS files, images, things under \fI\%MEDIA_URL\fP and so forth). If (such as CSS files, images, things under \fI\%MEDIA_URL\fP and so forth). If
you want to configure Django to serve static media, read you want to configure Django to serve static media, read
\fI\%How to manage static files (e.g. images, JavaScript, CSS)\fP\&. \fI\%How to manage static files (e.g. images, JavaScript, CSS)\fP\&.
.SS Serving with ASGI in development .SS Serving with ASGI in development
.sp .sp
Djangos \fBrunserver\fP command provides a WSGI server. In order to run under Django\(aqs \fBrunserver\fP command provides a WSGI server. In order to run under
ASGI you will need to use an \fI\%ASGI server\fP\&. ASGI you will need to use an \fI\%ASGI server\fP\&.
The Django Daphne project provides \fI\%Integration with runserver\fP that you can use. The Django Daphne project provides \fI\%Integration with runserver\fP that you can use.
.SS \fBsendtestemail\fP .SS \fBsendtestemail\fP
@ -1411,7 +1411,7 @@ django\-admin shell \-i bpython
.UNINDENT .UNINDENT
.UNINDENT .UNINDENT
.sp .sp
If you have a “rich” shell installed but want to force use of the “plain” If you have a \(dqrich\(dq shell installed but want to force use of the \(dqplain\(dq
Python interpreter, use \fBpython\fP as the interface name, like so: Python interpreter, use \fBpython\fP as the interface name, like so:
.INDENT 0.0 .INDENT 0.0
.INDENT 3.5 .INDENT 3.5
@ -1426,7 +1426,7 @@ django\-admin shell \-i python
.B \-\-no\-startup .B \-\-no\-startup
.UNINDENT .UNINDENT
.sp .sp
Disables reading the startup script for the “plain” Python interpreter. By Disables reading the startup script for the \(dqplain\(dq Python interpreter. By
default, the script pointed to by the \X'tty: link https://docs.python.org/3/using/cmdline.html#envvar-PYTHONSTARTUP'\fI\%PYTHONSTARTUP\fP\X'tty: link' environment default, the script pointed to by the \X'tty: link https://docs.python.org/3/using/cmdline.html#envvar-PYTHONSTARTUP'\fI\%PYTHONSTARTUP\fP\X'tty: link' environment
variable or the \fB~/.pythonrc.py\fP script is read. variable or the \fB~/.pythonrc.py\fP script is read.
.INDENT 0.0 .INDENT 0.0
@ -1529,7 +1529,7 @@ Prints the SQL for the named migration. This requires an active database
connection, which it will use to resolve constraint names; this means you must connection, which it will use to resolve constraint names; this means you must
generate the SQL against a copy of the database you wish to later apply it on. generate the SQL against a copy of the database you wish to later apply it on.
.sp .sp
Note that \fBsqlmigrate\fP doesnt colorize its output. Note that \fBsqlmigrate\fP doesn\(aqt colorize its output.
.INDENT 0.0 .INDENT 0.0
.TP .TP
.B \-\-backwards .B \-\-backwards
@ -1620,7 +1620,7 @@ By default, \X'tty: link https://github.com/django/django/blob/main/django/conf/
the app directory will be created in the current working directory. the app directory will be created in the current working directory.
.sp .sp
If the optional destination is provided, Django will use that existing If the optional destination is provided, Django will use that existing
directory rather than creating a new one. You can use . to denote the current directory rather than creating a new one. You can use \(aq.\(aq to denote the current
working directory. working directory.
.sp .sp
For example: For example:
@ -1657,7 +1657,7 @@ Django will also accept URLs (\fBhttp\fP, \fBhttps\fP, \fBftp\fP) to compressed
archives with the app template files, downloading and extracting them on the archives with the app template files, downloading and extracting them on the
fly. fly.
.sp .sp
For example, taking advantage of GitHubs feature to expose repositories as For example, taking advantage of GitHub\(aqs feature to expose repositories as
zip files, you can use a URL like: zip files, you can use a URL like:
.INDENT 0.0 .INDENT 0.0
.INDENT 3.5 .INDENT 3.5
@ -1695,18 +1695,18 @@ The \fI\%template context\fP used for all matching
files is: files is:
.INDENT 0.0 .INDENT 0.0
.IP \(bu 2 .IP \(bu 2
Any option passed to the \fBstartapp\fP command (among the commands supported Any option passed to the \fBstartapp\fP command (among the command\(aqs supported
options) options)
.IP \(bu 2 .IP \(bu 2
\fBapp_name\fP the app name as passed to the command \fBapp_name\fP \-\- the app name as passed to the command
.IP \(bu 2 .IP \(bu 2
\fBapp_directory\fP the full path of the newly created app \fBapp_directory\fP \-\- the full path of the newly created app
.IP \(bu 2 .IP \(bu 2
\fBcamel_case_app_name\fP the app name in camel case format \fBcamel_case_app_name\fP \-\- the app name in camel case format
.IP \(bu 2 .IP \(bu 2
\fBdocs_version\fP the version of the documentation: \fB\(aqdev\(aq\fP or \fB\(aq1.x\(aq\fP \fBdocs_version\fP \-\- the version of the documentation: \fB\(aqdev\(aq\fP or \fB\(aq1.x\(aq\fP
.IP \(bu 2 .IP \(bu 2
\fBdjango_version\fP the version of Django, e.g. \fB\(aq2.0.3\(aq\fP \fBdjango_version\fP \-\- the version of Django, e.g. \fB\(aq2.0.3\(aq\fP
.UNINDENT .UNINDENT
.sp .sp
\fBWARNING:\fP \fBWARNING:\fP
@ -1719,7 +1719,7 @@ contains a docstring explaining a particular feature related
to template rendering, it might result in an incorrect example. to template rendering, it might result in an incorrect example.
.sp .sp
To work around this problem, you can use the \fI\%templatetag\fP To work around this problem, you can use the \fI\%templatetag\fP
template tag to “escape” the various parts of the template syntax. template tag to \(dqescape\(dq the various parts of the template syntax.
.sp .sp
In addition, to allow Python template files that contain Django template In addition, to allow Python template files that contain Django template
language syntax while also preventing packaging systems from trying to language syntax while also preventing packaging systems from trying to
@ -1760,7 +1760,7 @@ will be created in the current working directory.
.sp .sp
If the optional destination is provided, Django will use that existing If the optional destination is provided, Django will use that existing
directory as the project directory, and create \fBmanage.py\fP and the project directory as the project directory, and create \fBmanage.py\fP and the project
package within it. Use . to denote the current working directory. package within it. Use \(aq.\(aq to denote the current working directory.
.sp .sp
For example: For example:
.INDENT 0.0 .INDENT 0.0
@ -1805,18 +1805,18 @@ directories named \fB__pycache__\fP or starting with \fB\&.\fP will be excluded.
The \fI\%template context\fP used is: The \fI\%template context\fP used is:
.INDENT 0.0 .INDENT 0.0
.IP \(bu 2 .IP \(bu 2
Any option passed to the \fBstartproject\fP command (among the commands Any option passed to the \fBstartproject\fP command (among the command\(aqs
supported options) supported options)
.IP \(bu 2 .IP \(bu 2
\fBproject_name\fP the project name as passed to the command \fBproject_name\fP \-\- the project name as passed to the command
.IP \(bu 2 .IP \(bu 2
\fBproject_directory\fP the full path of the newly created project \fBproject_directory\fP \-\- the full path of the newly created project
.IP \(bu 2 .IP \(bu 2
\fBsecret_key\fP a random key for the \fI\%SECRET_KEY\fP setting \fBsecret_key\fP \-\- a random key for the \fI\%SECRET_KEY\fP setting
.IP \(bu 2 .IP \(bu 2
\fBdocs_version\fP the version of the documentation: \fB\(aqdev\(aq\fP or \fB\(aq1.x\(aq\fP \fBdocs_version\fP \-\- the version of the documentation: \fB\(aqdev\(aq\fP or \fB\(aq1.x\(aq\fP
.IP \(bu 2 .IP \(bu 2
\fBdjango_version\fP the version of Django, e.g. \fB\(aq2.0.3\(aq\fP \fBdjango_version\fP \-\- the version of Django, e.g. \fB\(aq2.0.3\(aq\fP
.UNINDENT .UNINDENT
.sp .sp
Please also see the \fI\%rendering warning\fP and Please also see the \fI\%rendering warning\fP and
@ -1873,10 +1873,10 @@ before running the test suite.
.UNINDENT .UNINDENT
.sp .sp
Randomizes the order of tests before running them. This can help detect tests Randomizes the order of tests before running them. This can help detect tests
that arent properly isolated. The test order generated by this option is a that aren\(aqt properly isolated. The test order generated by this option is a
deterministic function of the integer seed given. When no seed is passed, a deterministic function of the integer seed given. When no seed is passed, a
seed is chosen randomly and printed to the console. To repeat a particular test seed is chosen randomly and printed to the console. To repeat a particular test
order, pass a seed. The test orders generated by this option preserve Djangos order, pass a seed. The test orders generated by this option preserve Django\(aqs
\fI\%guarantees on test order\fP\&. They also keep tests grouped \fI\%guarantees on test order\fP\&. They also keep tests grouped
by test case class. by test case class.
.sp .sp
@ -1891,7 +1891,7 @@ order of the original tests will be the same in the new order.
.UNINDENT .UNINDENT
.sp .sp
Sorts test cases in the opposite execution order. This may help in debugging Sorts test cases in the opposite execution order. This may help in debugging
the side effects of tests that arent properly isolated. \fI\%Grouping by test the side effects of tests that aren\(aqt properly isolated. \fI\%Grouping by test
class\fP is preserved when using this option. This can be used class\fP is preserved when using this option. This can be used
in conjunction with \fB\-\-shuffle\fP to reverse the order for a particular seed. in conjunction with \fB\-\-shuffle\fP to reverse the order for a particular seed.
.INDENT 0.0 .INDENT 0.0
@ -1931,7 +1931,7 @@ subprocesses. If there are fewer test case classes than configured processes,
Django will reduce the number of processes accordingly. Django will reduce the number of processes accordingly.
.sp .sp
Each process gets its own database. You must ensure that different test case Each process gets its own database. You must ensure that different test case
classes dont access the same resources. For instance, test case classes that classes don\(aqt access the same resources. For instance, test case classes that
touch the filesystem should create a temporary directory for their own use. touch the filesystem should create a temporary directory for their own use.
.sp .sp
\fBNOTE:\fP \fBNOTE:\fP
@ -1954,12 +1954,12 @@ $ python \-m pip install tblib
.UNINDENT .UNINDENT
.UNINDENT .UNINDENT
.sp .sp
This feature isnt available on Windows. It doesnt work with the Oracle This feature isn\(aqt available on Windows. It doesn\(aqt work with the Oracle
database backend either. database backend either.
.sp .sp
If you want to use \X'tty: link https://docs.python.org/3/library/pdb.html#module-pdb'\fI\%pdb\fP\X'tty: link' while debugging tests, you must disable parallel If you want to use \X'tty: link https://docs.python.org/3/library/pdb.html#module-pdb'\fI\%pdb\fP\X'tty: link' while debugging tests, you must disable parallel
execution (\fB\-\-parallel=1\fP). Youll see something like \fBbdb.BdbQuit\fP if you execution (\fB\-\-parallel=1\fP). You\(aqll see something like \fBbdb.BdbQuit\fP if you
dont. don\(aqt.
.sp .sp
\fBWARNING:\fP \fBWARNING:\fP
.INDENT 0.0 .INDENT 0.0
@ -2057,7 +2057,7 @@ django\-admin testserver mydata.json
.UNINDENT .UNINDENT
.UNINDENT .UNINDENT
.sp .sp
would perform the following steps: \&...would perform the following steps:
.INDENT 0.0 .INDENT 0.0
.IP 1. 3 .IP 1. 3
Create a test database, as described in \fI\%The test database\fP\&. Create a test database, as described in \fI\%The test database\fP\&.
@ -2072,17 +2072,17 @@ this newly created test database instead of your production database.
This is useful in a number of ways: This is useful in a number of ways:
.INDENT 0.0 .INDENT 0.0
.IP \(bu 2 .IP \(bu 2
When youre writing \fI\%unit tests\fP of how your views When you\(aqre writing \fI\%unit tests\fP of how your views
act with certain fixture data, you can use \fBtestserver\fP to interact with act with certain fixture data, you can use \fBtestserver\fP to interact with
the views in a web browser, manually. the views in a web browser, manually.
.IP \(bu 2 .IP \(bu 2
Lets say youre developing your Django application and have a “pristine” Let\(aqs say you\(aqre developing your Django application and have a \(dqpristine\(dq
copy of a database that youd like to interact with. You can dump your copy of a database that you\(aqd like to interact with. You can dump your
database to a \fI\%fixture\fP (using the database to a \fI\%fixture\fP (using the
\fI\%dumpdata\fP command, explained above), then use \fBtestserver\fP to run \fI\%dumpdata\fP command, explained above), then use \fBtestserver\fP to run
your web application with that data. With this arrangement, you have the your web application with that data. With this arrangement, you have the
flexibility of messing up your data in any way, knowing that whatever data flexibility of messing up your data in any way, knowing that whatever data
changes youre making are only being made to a test database. changes you\(aqre making are only being made to a test database.
.UNINDENT .UNINDENT
.sp .sp
Note that this server does \fInot\fP automatically detect changes to your Python Note that this server does \fInot\fP automatically detect changes to your Python
@ -2111,7 +2111,7 @@ django\-admin testserver fixture1 fixture2 \-\-addrport 7000
.UNINDENT .UNINDENT
.sp .sp
(The above statements are equivalent. We include both of them to demonstrate (The above statements are equivalent. We include both of them to demonstrate
that it doesnt matter whether the options come before or after the fixture that it doesn\(aqt matter whether the options come before or after the fixture
arguments.) arguments.)
.sp .sp
To run on 1.2.3.4:7000 with a \fBtest\fP fixture: To run on 1.2.3.4:7000 with a \fBtest\fP fixture:
@ -2143,9 +2143,9 @@ their application.
.B django\-admin changepassword [<username>] .B django\-admin changepassword [<username>]
.UNINDENT .UNINDENT
.sp .sp
This command is only available if Djangos \fI\%authentication system\fP (\fBdjango.contrib.auth\fP) is installed. This command is only available if Django\(aqs \fI\%authentication system\fP (\fBdjango.contrib.auth\fP) is installed.
.sp .sp
Allows changing a users password. It prompts you to enter a new password twice Allows changing a user\(aqs password. It prompts you to enter a new password twice
for the given user. If the entries are identical, this immediately becomes the for the given user. If the entries are identical, this immediately becomes the
new password. If you do not supply a user, the command will attempt to change new password. If you do not supply a user, the command will attempt to change
the password whose username matches the current user. the password whose username matches the current user.
@ -2175,7 +2175,7 @@ django\-admin changepassword ringo
.B DJANGO_SUPERUSER_PASSWORD .B DJANGO_SUPERUSER_PASSWORD
.UNINDENT .UNINDENT
.sp .sp
This command is only available if Djangos \fI\%authentication system\fP (\fBdjango.contrib.auth\fP) is installed. This command is only available if Django\(aqs \fI\%authentication system\fP (\fBdjango.contrib.auth\fP) is installed.
.sp .sp
Creates a superuser account (a user who has all permissions). This is Creates a superuser account (a user who has all permissions). This is
useful if you need to create an initial superuser account or if you need to useful if you need to create an initial superuser account or if you need to
@ -2223,7 +2223,7 @@ Specifies the database into which the superuser object will be saved.
.sp .sp
You can subclass the management command and override \fBget_input_data()\fP if you You can subclass the management command and override \fBget_input_data()\fP if you
want to customize data input and validation. Consult the source code for want to customize data input and validation. Consult the source code for
details on the existing implementation and the methods parameters. For example, details on the existing implementation and the method\(aqs parameters. For example,
it could be useful if you have a \fBForeignKey\fP in it could be useful if you have a \fBForeignKey\fP in
\fI\%REQUIRED_FIELDS\fP and want to \fI\%REQUIRED_FIELDS\fP and want to
allow creating an instance instead of entering the primary key of an existing allow creating an instance instead of entering the primary key of an existing
@ -2235,11 +2235,11 @@ instance.
.B django\-admin remove_stale_contenttypes .B django\-admin remove_stale_contenttypes
.UNINDENT .UNINDENT
.sp .sp
This command is only available if Djangos \fI\%contenttypes app\fP (\fI\%django.contrib.contenttypes\fP) is installed. This command is only available if Django\(aqs \fI\%contenttypes app\fP (\fI\%django.contrib.contenttypes\fP) is installed.
.sp .sp
Deletes stale content types (from deleted models) in your database. Any objects Deletes stale content types (from deleted models) in your database. Any objects
that depend on the deleted content types will also be deleted. A list of that depend on the deleted content types will also be deleted. A list of
deleted objects will be displayed before you confirm its okay to proceed with deleted objects will be displayed before you confirm it\(aqs okay to proceed with
the deletion. the deletion.
.INDENT 0.0 .INDENT 0.0
.TP .TP
@ -2292,7 +2292,7 @@ allows for the following options by default:
.UNINDENT .UNINDENT
.sp .sp
Adds the given filesystem path to the Python \X'tty: link https://docs.python.org/3/library/sys.html#sys.path'\fI\%sys.path\fP\X'tty: link' module Adds the given filesystem path to the Python \X'tty: link https://docs.python.org/3/library/sys.html#sys.path'\fI\%sys.path\fP\X'tty: link' module
attribute. If this isnt provided, \fBdjango\-admin\fP will use the attribute. If this isn\(aqt provided, \fBdjango\-admin\fP will use the
\X'tty: link https://docs.python.org/3/using/cmdline.html#envvar-PYTHONPATH'\fI\%PYTHONPATH\fP\X'tty: link' environment variable. \X'tty: link https://docs.python.org/3/using/cmdline.html#envvar-PYTHONPATH'\fI\%PYTHONPATH\fP\X'tty: link' environment variable.
.sp .sp
This option is unnecessary in \fBmanage.py\fP, because it takes care of setting This option is unnecessary in \fBmanage.py\fP, because it takes care of setting
@ -2313,7 +2313,7 @@ django\-admin migrate \-\-pythonpath=\(aq/home/djangoprojects/myproject\(aq
.UNINDENT .UNINDENT
.sp .sp
Specifies the settings module to use. The settings module should be in Python Specifies the settings module to use. The settings module should be in Python
package syntax, e.g. \fBmysite.settings\fP\&. If this isnt provided, package syntax, e.g. \fBmysite.settings\fP\&. If this isn\(aqt provided,
\fBdjango\-admin\fP will use the \fI\%DJANGO_SETTINGS_MODULE\fP environment \fBdjango\-admin\fP will use the \fI\%DJANGO_SETTINGS_MODULE\fP environment
variable. variable.
.sp .sp
@ -2432,7 +2432,7 @@ django\-admin migrate \-\-skip\-checks
.sp .sp
The \fBdjango\-admin\fP / \fBmanage.py\fP commands will use pretty The \fBdjango\-admin\fP / \fBmanage.py\fP commands will use pretty
color\-coded output if your terminal supports ANSI\-colored output. It color\-coded output if your terminal supports ANSI\-colored output. It
wont use the color codes if youre piping the commands output to won\(aqt use the color codes if you\(aqre piping the command\(aqs output to
another program unless the \fI\%\-\-force\-color\fP option is used. another program unless the \fI\%\-\-force\-color\fP option is used.
.SS Windows support .SS Windows support
.sp .sp
@ -2440,7 +2440,7 @@ On Windows 10, the \X'tty: link https://www.microsoft.com/en-us/p/windows-termin
(where virtual terminal processing is enabled) allow colored output, and are (where virtual terminal processing is enabled) allow colored output, and are
supported by default. supported by default.
.sp .sp
Under Windows, the legacy \fBcmd.exe\fP native console doesnt support ANSI Under Windows, the legacy \fBcmd.exe\fP native console doesn\(aqt support ANSI
escape sequences so by default there is no color output. In this case either of escape sequences so by default there is no color output. In this case either of
two third\-party libraries are needed: two third\-party libraries are needed:
.INDENT 0.0 .INDENT 0.0
@ -2464,7 +2464,7 @@ of its services to color output just like on Unix\-based platforms.
.UNINDENT .UNINDENT
.sp .sp
Other modern terminal environments on Windows, that support terminal colors, Other modern terminal environments on Windows, that support terminal colors,
but which are not automatically detected as supported by Django, may “fake” the but which are not automatically detected as supported by Django, may \(dqfake\(dq the
installation of \fBANSICON\fP by setting the appropriate environmental variable, installation of \fBANSICON\fP by setting the appropriate environmental variable,
\fBANSICON=\(dqon\(dq\fP\&. \fBANSICON=\(dqon\(dq\fP\&.
.SS Custom colors .SS Custom colors
@ -2619,7 +2619,7 @@ overridden as specified.
If you use the Bash shell, consider installing the Django bash completion If you use the Bash shell, consider installing the Django bash completion
script, which lives in \X'tty: link https://github.com/django/django/blob/main/extras/django_bash_completion'\fI\%extras/django_bash_completion\fP\X'tty: link' in the Django source script, which lives in \X'tty: link https://github.com/django/django/blob/main/extras/django_bash_completion'\fI\%extras/django_bash_completion\fP\X'tty: link' in the Django source
distribution. It enables tab\-completion of \fBdjango\-admin\fP and distribution. It enables tab\-completion of \fBdjango\-admin\fP and
\fBmanage.py\fP commands, so you can, for instance \fBmanage.py\fP commands, so you can, for instance...
.INDENT 0.0 .INDENT 0.0
.IP \(bu 2 .IP \(bu 2
Type \fBdjango\-admin\fP\&. Type \fBdjango\-admin\fP\&.
@ -2677,7 +2677,7 @@ line. For example, \fBcall_command(\(aqflush\(aq, \(aq\-\-verbosity=0\(aq)\fP\&.
.TP .TP
.B \fB**options\fP .B \fB**options\fP
named options accepted on the command\-line. Options are passed to the command named options accepted on the command\-line. Options are passed to the command
without triggering the argument parser, which means youll need to pass the without triggering the argument parser, which means you\(aqll need to pass the
correct type. For example, \fBcall_command(\(aqflush\(aq, verbosity=0)\fP (zero must correct type. For example, \fBcall_command(\(aqflush\(aq, verbosity=0)\fP (zero must
be an integer rather than a string). be an integer rather than a string).
.UNINDENT .UNINDENT
@ -2722,7 +2722,7 @@ Some command options have different names when using \fBcall_command()\fP instea
of \fBdjango\-admin\fP or \fBmanage.py\fP\&. For example, \fBdjango\-admin of \fBdjango\-admin\fP or \fBmanage.py\fP\&. For example, \fBdjango\-admin
createsuperuser \-\-no\-input\fP translates to \fBcall_command(\(aqcreatesuperuser\(aq, createsuperuser \-\-no\-input\fP translates to \fBcall_command(\(aqcreatesuperuser\(aq,
interactive=False)\fP\&. To find what keyword argument name to use for interactive=False)\fP\&. To find what keyword argument name to use for
\fBcall_command()\fP, check the commands source code for the \fBdest\fP argument \fBcall_command()\fP, check the command\(aqs source code for the \fBdest\fP argument
passed to \fBparser.add_argument()\fP\&. passed to \fBparser.add_argument()\fP\&.
.sp .sp
Command options which take multiple options are passed a list: Command options which take multiple options are passed a list: