200
210
the default manager and it filters some of the available records, not all of the
201
211
objects will be dumped.
203
.. django-admin-option:: --exclude
205
.. versionadded:: 1.0
207
Exclude a specific application from the applications whose contents is
208
output. For example, to specifically exclude the `auth` application from
209
the output, you would call::
211
django-admin.py dumpdata --exclude=auth
213
If you want to exclude multiple applications, use multiple ``--exclude``
216
django-admin.py dumpdata --exclude=auth --exclude=contenttypes
219
213
.. django-admin-option:: --format <fmt>
221
By default, ``dumpdata`` will format its output in JSON, but you can use the
222
``--format`` option to specify another format. Currently supported formats
223
are listed in :ref:`serialization-formats`.
215
By default, ``dumpdata`` will format its output in JSON, but you can use the
216
``--format`` option to specify another format. Currently supported formats
217
are listed in :ref:`serialization-formats`.
225
219
.. django-admin-option:: --indent <num>
227
By default, ``dumpdata`` will output all data on a single line. This isn't
228
easy for humans to read, so you can use the ``--indent`` option to
229
pretty-print the output with a number of indentation spaces.
221
By default, ``dumpdata`` will output all data on a single line. This isn't
222
easy for humans to read, so you can use the ``--indent`` option to
223
pretty-print the output with a number of indentation spaces.
225
.. versionadded:: 1.0
227
The :djadminopt:`--exclude` option may be provided to prevent specific
228
applications from being dumped.
231
230
.. versionadded:: 1.1
236
235
rather than the entire application. You can also mix application names and
238
.. versionadded:: 1.2
240
The :djadminopt:`--database` option can be used to specify the database
241
onto which the data will be loaded.
243
.. django-admin-option:: --natural
245
.. versionadded:: 1.2
247
Use :ref:`natural keys <topics-serialization-natural-keys>` to represent
248
any foreign key and many-to-many relationship with a model that provides
249
a natural key definition. If you are dumping ``contrib.auth`` ``Permission``
250
objects or ``contrib.contenttypes`` ``ContentType`` objects, you should
251
probably be using this flag.
242
.. django-admin: flush
256
.. django-admin:: flush
244
258
Returns the database to the state it was in immediately after syncdb was
245
259
executed. This means that all data will be removed from the database, any
246
260
post-synchronization handlers will be re-executed, and the ``initial_data``
247
261
fixture will be re-installed.
249
.. django-admin-option:: --noinput
251
Use the ``--noinput`` option to suppress all user prompting, such as "Are
252
you sure?" confirmation messages. This is useful if ``django-admin.py`` is
253
being executed as an unattended, automated script.
263
The :djadminopt:`--noinput` option may be provided to suppress all user
266
.. versionadded:: 1.2
268
The :djadminopt:`--database` option may be used to specify the database
275
.. django-admin:: inspectdb
258
277
Introspects the database tables in the database pointed-to by the
259
``DATABASE_NAME`` setting and outputs a Django model module (a ``models.py``
278
``NAME`` setting and outputs a Django model module (a ``models.py``
260
279
file) to standard output.
262
281
Use this if you have a legacy database with which you'd like to use Django.
379
411
references in your data files - MySQL doesn't provide a mechanism to
380
412
defer checking of row constraints until a transaction is committed.
414
Database-specific fixtures
415
~~~~~~~~~~~~~~~~~~~~~~~~~~
417
If you are in a multi-database setup, you may have fixture data that
418
you want to load onto one database, but not onto another. In this
419
situation, you can add database identifier into . If your
420
:setting:`DATABASES` setting has a 'master' database defined, you can
421
define the fixture ``mydata.master.json`` or
422
``mydata.master.json.gz``. This fixture will only be loaded if you
423
have specified that you want to load data onto the ``master``
429
.. django-admin:: makemessages
385
431
.. versionchanged:: 1.0
386
432
Before 1.0 this was the ``bin/make-messages.py`` command.
417
461
django-admin.py makemessages --locale=de --extension=html,txt --extension xml
422
Use the ``--locale`` or ``-l`` option to specify the locale to process.
463
Use the :djadminopt:`--locale` option to specify the locale to process.
426
467
django-admin.py makemessages --locale=br_PT
469
.. django-admin-option:: --domain
431
471
Use the ``--domain`` or ``-d`` option to change the domain of the messages files.
432
472
Currently supported:
434
* ``django`` for all ``*.py`` and ``*.html`` files (default)
435
* ``djangojs`` for ``*.js`` files
437
.. _django-admin-reset:
474
* ``django`` for all ``*.py`` and ``*.html`` files (default)
475
* ``djangojs`` for ``*.js`` files
477
.. django-admin-option:: --symlinks
479
.. versionadded:: 1.2
481
Use the ``--symlinks`` or ``-s`` option to follow symlinks to directories when
482
looking for new translation strings.
486
django-admin.py makemessages --locale=de --symlinks
488
.. django-admin-option:: --ignore
490
Use the ``--ignore`` or ``-i`` option to ignore files or directories matching
491
the given `glob-style pattern`_. Use multiple times to ignore more.
493
These patterns are used by default: ``'CVS'``, ``'.*'``, ``'*~'``
497
django-admin.py makemessages --locale=en_US --ignore=apps/* --ignore=secret/*.html
499
.. _`glob-style pattern`: http://docs.python.org/library/glob.html
501
.. django-admin-option:: --no-default-ignore
503
Use the ``--no-default-ignore`` option to disable the default values of
504
:djadminopt:`--ignore`.
439
506
reset <appname appname ...>
440
507
---------------------------
509
.. django-admin:: reset
442
511
Executes the equivalent of ``sqlreset`` for the given app name(s).
447
Use the ``--noinput`` option to suppress all user prompting, such as
448
"Are you sure?" confirmation messages. This is useful if ``django-admin.py``
449
is being executed as an unattended, automated script.
513
The :djadminopt:`--noinput` option may be provided to suppress all user
516
.. versionadded:: 1.2
518
The :djadminopt:`--database` option can be used to specify the alias
519
of the database to reset.
451
521
runfcgi [options]
452
522
-----------------
524
.. django-admin:: runfcgi
454
526
Starts a set of FastCGI processes suitable for use with any Web server that
455
527
supports the FastCGI protocol. See the :ref:`FastCGI deployment documentation
456
528
<howto-deployment-fastcgi>` for details. Requires the Python FastCGI module from
557
631
sql <appname appname ...>
558
632
-------------------------
634
.. django-admin:: sql
560
636
Prints the CREATE TABLE SQL statements for the given app name(s).
638
.. versionadded:: 1.2
640
The :djadminopt:`--database` option can be used to specify the database for
641
which to print the SQL.
562
643
sqlall <appname appname ...>
563
644
----------------------------
646
.. django-admin:: sqlall
565
648
Prints the CREATE TABLE and initial-data SQL statements for the given app name(s).
567
650
Refer to the description of ``sqlcustom`` for an explanation of how to
568
651
specify initial data.
653
.. versionadded:: 1.2
655
The :djadminopt:`--database` option can be used to specify the database for
656
which to print the SQL.
570
658
sqlclear <appname appname ...>
571
659
------------------------------
661
.. django-admin:: sqlclear
573
663
Prints the DROP TABLE SQL statements for the given app name(s).
665
.. versionadded:: 1.2
667
The :djadminopt:`--database` option can be used to specify the database for
668
which to print the SQL.
575
670
sqlcustom <appname appname ...>
576
671
-------------------------------
673
.. django-admin:: sqlcustom
578
675
Prints the custom SQL statements for the given app name(s).
580
677
For each model in each specified app, this command looks for the file
592
689
Note that the order in which the SQL files are processed is undefined.
691
.. versionadded:: 1.2
693
The :djadminopt:`--database` option can be used to specify the database for
694
which to print the SQL.
597
Prints the SQL statements that would be executed for the `flush`_ command.
699
.. django-admin:: sqlflush
701
Prints the SQL statements that would be executed for the :djadmin:`flush`
704
.. versionadded:: 1.2
706
The :djadminopt:`--database` option can be used to specify the database for
707
which to print the SQL.
599
709
sqlindexes <appname appname ...>
600
710
--------------------------------
712
.. django-admin:: sqlindexes
602
714
Prints the CREATE INDEX SQL statements for the given app name(s).
716
.. versionadded:: 1.2
718
The :djadminopt:`--database` option can be used to specify the database for
719
which to print the SQL.
604
721
sqlreset <appname appname ...>
605
722
------------------------------
724
.. django-admin:: sqlreset
607
726
Prints the DROP TABLE SQL, then the CREATE TABLE SQL, for the given app name(s).
728
.. versionadded:: 1.2
730
The :djadminopt:`--database` option can be used to specify the database for
731
which to print the SQL.
609
733
sqlsequencereset <appname appname ...>
610
734
--------------------------------------
736
.. django-admin:: sqlsequencereset
612
738
Prints the SQL statements for resetting sequences for the given app name(s).
614
740
Sequences are indexes used by some database engines to track the next available
675
Use the ``--noinput`` option to suppress all user prompting, such as
676
"Are you sure?" confirmation messages. This is useful if ``django-admin.py``
677
is being executed as an unattended, automated script.
809
The :djadminopt:`--noinput` option may be provided to suppress all user
812
.. versionadded:: 1.2
814
The :djadminopt:`--database` option can be used to specify the database to
817
test <app or test identifier>
818
-----------------------------
820
.. django-admin:: test
682
822
Runs tests for all installed models. See :ref:`topics-testing` for more
825
.. versionadded:: 1.2
826
.. django-admin-option:: --failfast
688
Use the ``--noinput`` option to suppress all user prompting, such as
689
"Are you sure?" confirmation messages. This is useful if ``django-admin.py``
690
is being executed as an unattended, automated script.
828
Use the :djadminopt:`--failfast` option to stop running tests and report the failure
829
immediately after a test fails.
692
831
testserver <fixture fixture ...>
693
832
--------------------------------
834
.. django-admin:: testserver
695
836
.. versionadded:: 1.0
697
838
Runs a Django development server (as in ``runserver``) using data from the
819
955
* ``1`` means normal output (default).
820
956
* ``2`` means verbose output.
961
The following options are not available on every commands, but they are
962
common to a number of commands.
964
.. django-admin-option:: --database
966
.. versionadded:: 1.2
968
Used to specify the database on which a command will operate. If not
969
specified, this option will default to an alias of ``default``.
971
For example, to dump data from the database with the alias ``master``::
973
django-admin.py dumpdata --database=master
975
.. django-admin-option:: --exclude
977
Exclude a specific application from the applications whose contents is
978
output. For example, to specifically exclude the `auth` application from
979
the output of dumpdata, you would call::
981
django-admin.py dumpdata --exclude=auth
983
If you want to exclude multiple applications, use multiple ``--exclude``
986
django-admin.py dumpdata --exclude=auth --exclude=contenttypes
988
.. django-admin-option:: --locale
990
Use the ``--locale`` or ``-l`` option to specify the locale to process.
991
If not provided all locales are processed.
993
.. django-admin-option:: --noinput
995
Use the ``--noinput`` option to suppress all user prompting, such as "Are
996
you sure?" confirmation messages. This is useful if ``django-admin.py`` is
997
being executed as an unattended, automated script.
1002
.. _syntax-coloring:
828
The ``django-admin.py`` / ``manage.py`` commands that output SQL to standard
829
output will use pretty color-coded output if your terminal supports
830
ANSI-colored output. It won't use the color codes if you're piping the
831
command's output to another program.
1007
The ``django-admin.py`` / ``manage.py`` commands will use pretty
1008
color-coded output if your terminal supports ANSI-colored output. It
1009
won't use the color codes if you're piping the command's output to
1012
The colors used for syntax highlighting can be customized. Django
1013
ships with three color palettes:
1015
* ``dark``, suited to terminals that show white text on a black
1016
background. This is the default palette.
1018
* ``light``, suited to terminals that show black text on a white
1021
* ``nocolor``, which disables syntax highlighting.
1023
You select a palette by setting a ``DJANGO_COLORS`` environment
1024
variable to specify the palette you want to use. For example, to
1025
specify the ``light`` palette under a Unix or OS/X BASH shell, you
1026
would run the following at a command prompt::
1028
export DJANGO_COLORS="light"
1030
You can also customize the colors that are used. Django specifies a
1031
number of roles in which color is used:
1033
* ``error`` - A major error.
1034
* ``notice`` - A minor error.
1035
* ``sql_field`` - The name of a model field in SQL.
1036
* ``sql_coltype`` - The type of a model field in SQL.
1037
* ``sql_keyword`` - A SQL keyword.
1038
* ``sql_table`` - The name of a model in SQL.
1039
* ``http_info`` - A 1XX HTTP Informational server response.
1040
* ``http_success`` - A 2XX HTTP Success server response.
1041
* ``http_not_modified`` - A 304 HTTP Not Modified server response.
1042
* ``http_redirect`` - A 3XX HTTP Redirect server response other than 304.
1043
* ``http_not_found`` - A 404 HTTP Not Found server response.
1044
* ``http_bad_request`` - A 4XX HTTP Bad Request server response other than 404.
1045
* ``http_server_error`` - A 5XX HTTP Server Error response.
1047
Each of these roles can be assigned a specific foreground and
1048
background color, from the following list:
1059
Each of these colors can then be modified by using the following
1068
A color specification follows one of the the following patterns:
1072
* ``role=fg,option,option``
1073
* ``role=fg/bg,option,option``
1075
where ``role`` is the name of a valid color role, ``fg`` is the
1076
foreground color, ``bg`` is the background color and each ``option``
1077
is one of the color modifying options. Multiple color specifications
1078
are then separated by semicolon. For example::
1080
export DJANGO_COLORS="error=yellow/blue,blink;notice=magenta"
1082
would specify that errors be displayed using blinking yellow on blue,
1083
and notices displayed using magenta. All other color roles would be
1086
Colors can also be specified by extending a base palette. If you put
1087
a palette name in a color specification, all the colors implied by that
1088
palette will be loaded. So::
1090
export DJANGO_COLORS="light;error=yellow/blue,blink;notice=magenta"
1092
would specify the use of all the colors in the light color palette,
1093
*except* for the colors for errors and notices which would be
1094
overridden as specified.