38
``django-admin.py action [options]``
40
``manage.py action [options]``
42
``action`` should be one of the actions listed in this document. ``options``,
43
which is optional, should be zero or more of the options listed in this
46
Run ``django-admin.py --help`` to display a help message that includes a terse
47
list of all available actions and options.
49
Most actions take a list of ``appname``s. An ``appname`` is the basename of the
50
package containing your models. For example, if your ``INSTALLED_APPS``
51
contains the string ``'mysite.blog'``, the ``appname`` is ``blog``.
56
adminindex [appname appname ...]
38
``django-admin.py <subcommand> [options]``
40
``manage.py <subcommand> [options]``
42
``subcommand`` should be one of the subcommands listed in this document.
43
``options``, which is optional, should be zero or more of the options available
44
for the given subcommand.
49
In Django 0.96, run ``django-admin.py --help`` to display a help message that
50
includes a terse list of all available subcommands and options.
52
In the Django development version, run ``django-admin.py help`` to display a
53
list of all available subcommands. Run ``django-admin.py help <subcommand>``
54
to display a description of the given subcommand and a list of its available
60
Many subcommands take a list of "app names." An "app name" is the basename of
61
the package containing your models. For example, if your ``INSTALLED_APPS``
62
contains the string ``'mysite.blog'``, the app name is ``blog``.
64
Determining the version
65
-----------------------
67
Run ``django-admin.py --version`` to display the current Django version.
78
adminindex <appname appname ...>
57
79
--------------------------------
59
Prints the admin-index template snippet for the given appnames.
81
Prints the admin-index template snippet for the given app name(s).
61
83
Use admin-index template snippets if you want to customize the look and feel of
62
84
your admin's index page. See `Tutorial 2`_ for more information.
64
86
.. _Tutorial 2: ../tutorial02/
66
createcachetable [tablename]
88
createcachetable <tablename>
67
89
----------------------------
69
91
Creates a cache table named ``tablename`` for use with the database cache
70
backend. See the `cache documentation`_ for more information.
92
backend. See the `cache documentation`_ for more information.
72
94
.. _cache documentation: ../cache/
100
122
Note that Django's default settings live in ``django/conf/global_settings.py``,
101
123
if you're ever curious to see the full list of defaults.
103
dumpdata [appname appname ...]
125
dumpdata <appname appname ...>
104
126
------------------------------
106
Output to standard output all data in the database associated with the named
128
Outputs to standard output all data in the database associated with the named
109
By default, the database will be dumped in JSON format. If you want the output
110
to be in another format, use the ``--format`` option (e.g., ``format=xml``).
111
You may specify any Django serialization backend (including any user specified
112
serialization backends named in the ``SERIALIZATION_MODULES`` setting). The
113
``--indent`` option can be used to pretty-print the output.
115
131
If no application name is provided, all installed applications will be dumped.
117
133
The output of ``dumpdata`` can be used as input for ``loaddata``.
138
By default, ``dumpdata`` will format its output in JSON, but you can use the
139
``--format`` option to specify another format. Currently supported formats are
140
listed in `Serialization formats`_.
144
django-admin.py dumpdata --format=xml
146
.. _Serialization formats: ../serialization/#serialization-formats
151
By default, ``dumpdata`` will output all data on a single line. This isn't easy
152
for humans to read, so you can use the ``--indent`` option to pretty-print the
153
output with a number of indentation spaces.
157
django-admin.py dumpdata --indent=4
122
Return the database to the state it was in immediately after syncdb was
162
Returns the database to the state it was in immediately after syncdb was
123
163
executed. This means that all data will be removed from the database, any
124
164
post-synchronization handlers will be re-executed, and the ``initial_data``
125
165
fixture will be re-installed.
131
171
tables that are represented by Django models and are activated in
132
172
``INSTALLED_APPS``.
177
Use the ``--noinput`` option to suppress all user prompting, such as
178
"Are you sure?" confirmation messages. This is useful if ``django-admin.py``
179
is being executed as an unattended, automated script.
184
Use ``--verbosity`` to specify the amount of notification and debug information
185
that ``django-admin.py`` should print to the console.
187
* ``0`` means no input.
188
* ``1`` means normal input (default).
189
* ``2`` means verbose input.
193
django-admin.py flush --verbosity=2
172
233
``inspectdb`` works with PostgreSQL, MySQL and SQLite. Foreign-key detection
173
234
only works in PostgreSQL and with certain types of MySQL tables.
175
loaddata [fixture fixture ...]
236
loaddata <fixture fixture ...>
176
237
------------------------------
178
239
Searches for and loads the contents of the named fixture into the database.
180
A *Fixture* is a collection of files that contain the serialized contents of
181
the database. Each fixture has a unique name; however, the files that
182
comprise the fixture can be distributed over multiple directories, in
183
multiple applications.
241
A *fixture* is a collection of files that contain the serialized contents of
242
the database. Each fixture has a unique name, and the files that comprise the
243
fixture can be distributed over multiple directories, in multiple applications.
185
245
Django will search in three locations for fixtures:
240
300
references in your data files - MySQL doesn't provide a mechanism to
241
301
defer checking of row constraints until a transaction is committed.
243
reset [appname appname ...]
306
Use ``--verbosity`` to specify the amount of notification and debug information
307
that ``django-admin.py`` should print to the console.
309
* ``0`` means no input.
310
* ``1`` means normal input (default).
311
* ``2`` means verbose input.
315
django-admin.py loaddata --verbosity=2
317
reset <appname appname ...>
244
318
---------------------------
246
Executes the equivalent of ``sqlreset`` for the given appnames.
320
Executes the equivalent of ``sqlreset`` for the given app name(s).
325
Use the ``--noinput`` option to suppress all user prompting, such as
326
"Are you sure?" confirmation messages. This is useful if ``django-admin.py``
327
is being executed as an unattended, automated script.
248
329
runfcgi [options]
249
330
-----------------
251
Starts a set of FastCGI processes suitable for use with any web server
252
which supports the FastCGI protocol. See the `FastCGI deployment
332
Starts a set of FastCGI processes suitable for use with any Web server
333
that supports the FastCGI protocol. See the `FastCGI deployment
253
334
documentation`_ for details. Requires the Python FastCGI module from
289
370
machines on the network, use its own IP address (e.g. ``192.168.2.1``) or
376
Use the ``--adminmedia`` option to tell Django where to find the various CSS
377
and JavaScript files for the Django admin interface. Normally, the development
378
server serves these files out of the Django source tree magically, but you'd
379
want to use this if you made any changes to those files for your own site.
383
django-admin.py runserver --adminmedia=/tmp/new-admin-style/
388
Use the ``--noreload`` option to disable the use of the auto-reloader. This
389
means any Python code changes you make while the server is running will *not*
390
take effect if the particular Python modules have already been loaded into
393
Examples of using different ports and addresses
394
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
396
Port 8000 on IP address 127.0.0.1::
398
django-admin.py runserver
400
Port 8000 on IP address 1.2.3.4::
402
django-admin.py runserver 1.2.3.4:8000
295
404
Port 7000 on IP address 127.0.0.1::
332
441
.. _IPython: http://ipython.scipy.org/
334
sql [appname appname ...]
443
sql <appname appname ...>
335
444
-------------------------
337
Prints the CREATE TABLE SQL statements for the given appnames.
446
Prints the CREATE TABLE SQL statements for the given app name(s).
339
sqlall [appname appname ...]
448
sqlall <appname appname ...>
340
449
----------------------------
342
Prints the CREATE TABLE and initial-data SQL statements for the given appnames.
451
Prints the CREATE TABLE and initial-data SQL statements for the given app name(s).
344
453
Refer to the description of ``sqlcustom`` for an explanation of how to
345
454
specify initial data.
347
sqlclear [appname appname ...]
456
sqlclear <appname appname ...>
348
457
------------------------------
350
Prints the DROP TABLE SQL statements for the given appnames.
459
Prints the DROP TABLE SQL statements for the given app name(s).
352
sqlcustom [appname appname ...]
461
sqlcustom <appname appname ...>
353
462
-------------------------------
355
Prints the custom SQL statements for the given appnames.
464
Prints the custom SQL statements for the given app name(s).
357
466
For each model in each specified app, this command looks for the file
358
``<appname>/sql/<modelname>.sql``, where ``<appname>`` is the given appname and
467
``<appname>/sql/<modelname>.sql``, where ``<appname>`` is the given app name and
359
468
``<modelname>`` is the model's name in lowercase. For example, if you have an
360
469
app ``news`` that includes a ``Story`` model, ``sqlcustom`` will attempt
361
470
to read a file ``news/sql/story.sql`` and append it to the output of this
374
483
Prints the SQL statements that would be executed for the `flush`_ command.
376
sqlindexes [appname appname ...]
485
sqlindexes <appname appname ...>
377
486
--------------------------------
379
Prints the CREATE INDEX SQL statements for the given appnames.
488
Prints the CREATE INDEX SQL statements for the given app name(s).
381
sqlreset [appname appname ...]
490
sqlreset <appname appname ...>
382
491
------------------------------
384
Prints the DROP TABLE SQL, then the CREATE TABLE SQL, for the given appnames.
493
Prints the DROP TABLE SQL, then the CREATE TABLE SQL, for the given app name(s).
386
sqlsequencereset [appname appname ...]
495
sqlsequencereset <appname appname ...>
387
496
--------------------------------------
389
Prints the SQL statements for resetting sequences for the given
498
Prints the SQL statements for resetting sequences for the given app name(s).
392
500
See http://simon.incutio.com/archive/2004/04/21/postgres for more information.
395
503
------------------
397
505
Creates a Django app directory structure for the given app name in the current
400
startproject [projectname]
508
startproject <projectname>
401
509
--------------------------
403
511
Creates a Django project directory structure for the given project name in the
435
543
documentation for ``loaddata`` for details on the specification of fixture
549
Use ``--verbosity`` to specify the amount of notification and debug information
550
that ``django-admin.py`` should print to the console.
552
* ``0`` means no input.
553
* ``1`` means normal input (default).
554
* ``2`` means verbose input.
558
django-admin.py syncdb --verbosity=2
563
Use the ``--noinput`` option to suppress all user prompting, such as
564
"Are you sure?" confirmation messages. This is useful if ``django-admin.py``
565
is being executed as an unattended, automated script.
441
Discover and run tests for all installed models. See `Testing Django applications`_ for more information.
570
Runs tests for all installed models. See `Testing Django applications`_
571
for more information.
443
573
.. _testing Django applications: ../testing/
445
testserver [fixture fixture ...]
578
Use the ``--noinput`` option to suppress all user prompting, such as
579
"Are you sure?" confirmation messages. This is useful if ``django-admin.py``
580
is being executed as an unattended, automated script.
585
Use ``--verbosity`` to specify the amount of notification and debug information
586
that ``django-admin.py`` should print to the console.
588
* ``0`` means no input.
589
* ``1`` means normal input (default).
590
* ``2`` means verbose input.
594
django-admin.py test --verbosity=2
596
testserver <fixture fixture ...>
446
597
--------------------------------
448
599
**New in Django development version**
476
627
in any way, knowing that whatever data changes you're making are only
477
628
being made to a test database.
479
Note that this server can only run on the default port on localhost; it does
480
not yet accept a ``host`` or ``port`` parameter.
482
Also note that it does *not* automatically detect changes to your Python source
483
code (as ``runserver`` does). It does, however, detect changes to templates.
630
Note that this server does *not* automatically detect changes to your Python
631
source code (as ``runserver`` does). It does, however, detect changes to
485
634
.. _unit tests: ../testing/
636
--addrport [port number or ipaddr:port]
637
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
639
Use ``--addrport`` to specify a different port, or IP address and port, from
640
the default of 127.0.0.1:8000. This value follows exactly the same format and
641
serves exactly the same function as the argument to the ``runserver`` subcommand.
645
To run the test server on port 7000 with ``fixture1`` and ``fixture2``::
647
django-admin.py testserver --addrport 7000 fixture1 fixture2
648
django-admin.py testserver fixture1 fixture2 --addrport 7000
650
(The above statements are equivalent. We include both of them to demonstrate
651
that it doesn't matter whether the options come before or after the fixture
654
To run on 1.2.3.4:7000 with a `test` fixture::
656
django-admin.py testserver --addrport 1.2.3.4:7000 test
661
Use ``--verbosity`` to specify the amount of notification and debug information
662
that ``django-admin.py`` should print to the console.
664
* ``0`` means no input.
665
* ``1`` means normal input (default).
666
* ``2`` means verbose input.
670
django-admin.py testserver --verbosity=2
490
675
Validates all installed models (according to the ``INSTALLED_APPS`` setting)
491
676
and prints validation errors to standard output.
681
Although some subcommands may allow their own custom options, every subcommand
682
allows for the following options:
689
django-admin.py syncdb --pythonpath='/home/djangoprojects/myproject'
691
Adds the given filesystem path to the Python `import search path`_. If this
692
isn't provided, ``django-admin.py`` will use the ``PYTHONPATH`` environment
695
Note that this option is unnecessary in ``manage.py``, because it takes care of
696
setting the Python path for you.
698
.. _import search path: http://diveintopython.org/getting_to_know_python/everything_is_an_object.html
508
712
Note that this option is unnecessary in ``manage.py``, because it takes care of
509
713
setting ``DJANGO_SETTINGS_MODULE`` for you.
516
django-admin.py syncdb --pythonpath='/home/djangoprojects/myproject'
518
Adds the given filesystem path to the Python `import search path`_. If this
519
isn't provided, ``django-admin.py`` will use the ``PYTHONPATH`` environment
522
Note that this option is unnecessary in ``manage.py``, because it takes care of
523
setting the Python path for you.
525
.. _import search path: http://diveintopython.org/getting_to_know_python/everything_is_an_object.html
532
django-admin.py dumpdata --format=xml
534
Specifies the output format that will be used. The name provided must be the name
535
of a registered serializer.
540
Displays a help message that includes a terse list of all available actions and
548
django-admin.py dumpdata --indent=4
550
Specifies the number of spaces that will be used for indentation when
551
pretty-printing output. By default, output will *not* be pretty-printed.
552
Pretty-printing will only be enabled if the indent option is provided.
557
Inform django-admin that the user should NOT be prompted for any input. Useful
558
if the django-admin script will be executed as an unattended, automated
564
Disable the use of the auto-reloader when running the development server.
569
Displays the current Django version.
581
django-admin.py syncdb --verbosity=2
583
Verbosity determines the amount of notification and debug information that
584
will be printed to the console. '0' is no output, '1' is normal output,
585
and ``2`` is verbose output.
592
django-admin.py --adminmedia=/tmp/new-admin-style/
594
Tells Django where to find the various CSS and JavaScript files for the admin
595
interface when running the development server. Normally these files are served
596
out of the Django source tree, but because some designers customize these files
597
for their site, this option allows you to test against custom versions.
619
735
* Press [TAB] to see all available options.
620
736
* Type ``sql``, then [TAB], to see all available options whose names start
742
**New in Django development version**
744
Applications can register their own actions with ``manage.py``. For example,
745
you might want to add a ``manage.py`` action for a Django app that you're
748
To do this, just add a ``management/commands`` directory to your application.
749
Each Python module in that directory will be auto-discovered and registered as
750
a command that can be executed as an action when you run ``manage.py``::
762
In this example, the ``explode`` command will be made available to any project
763
that includes the ``fancy_blog`` application in ``settings.INSTALLED_APPS``.
765
The ``explode.py`` module has only one requirement -- it must define a class
766
called ``Command`` that extends ``django.core.management.base.BaseCommand``.
768
For more details on how to define your own commands, look at the code for the
769
existing ``django-admin.py`` commands, in ``/django/core/management/commands``.