Fixed #8639; documented the fact that the "startproject" command is invalid when...
[django.git] / docs / ref / django-admin.txt
blob26f136b2f7c7d332f76f50b55ca82b6712ac355f
1 .. _ref-django-admin:
3 =============================
4 django-admin.py and manage.py
5 =============================
7 ``django-admin.py`` is Django's command-line utility for administrative tasks.
8 This document outlines all it can do.
10 In addition, ``manage.py`` is automatically created in each Django project.
11 ``manage.py`` is a thin wrapper around ``django-admin.py`` that takes care of
12 two things for you before delegating to ``django-admin.py``:
14     * It puts your project's package on ``sys.path``.
16     * It sets the :envvar:`DJANGO_SETTINGS_MODULE` environment variable so that
17       it points to your project's ``settings.py`` file.
19 The ``django-admin.py`` script should be on your system path if you installed
20 Django via its ``setup.py`` utility. If it's not on your path, you can find it
21 in ``site-packages/django/bin`` within your Python installation. Consider
22 symlinking it from some place on your path, such as ``/usr/local/bin``.
24 For Windows users, who do not have symlinking functionality available, you can
25 copy ``django-admin.py`` to a location on your existing path or edit the
26 ``PATH`` settings (under ``Settings - Control Panel - System - Advanced -
27 Environment...``) to point to its installed location.
29 Generally, when working on a single Django project, it's easier to use
30 ``manage.py``. Use ``django-admin.py`` with ``DJANGO_SETTINGS_MODULE``, or the
31 ``--settings`` command line option, if you need to switch between multiple
32 Django settings files.
34 The command-line examples throughout this document use ``django-admin.py`` to
35 be consistent, but any example can use ``manage.py`` just as well.
37 Usage
38 =====
40 .. code-block:: bash
42     django-admin.py <subcommand> [options]
43     manage.py <subcommand> [options]
45 ``subcommand`` should be one of the subcommands listed in this document.
46 ``options``, which is optional, should be zero or more of the options available
47 for the given subcommand.
49 Getting runtime help
50 --------------------
52 .. django-admin-option:: --help
54 In Django 0.96, run ``django-admin.py --help`` to display a help message that
55 includes a terse list of all available subcommands and options.
57 In the Django development version, run ``django-admin.py help`` to display a
58 list of all available subcommands. Run ``django-admin.py help <subcommand>``
59 to display a description of the given subcommand and a list of its available
60 options.
62 App names
63 ---------
65 Many subcommands take a list of "app names." An "app name" is the basename of
66 the package containing your models. For example, if your ``INSTALLED_APPS``
67 contains the string ``'mysite.blog'``, the app name is ``blog``.
69 Determining the version
70 -----------------------
72 .. django-admin-option:: --version
74 Run ``django-admin.py --version`` to display the current Django version.
76 Examples of output::
78     0.95
79     0.96
80     0.97-pre-SVN-6069
82 Displaying debug output
83 -----------------------
85 .. django-admin-option:: --verbosity <amount>
87 Use ``--verbosity`` to specify the amount of notification and debug information
88 that ``django-admin.py`` should print to the console.
90     * ``0`` means no output.
91     * ``1`` means normal output (default).
92     * ``2`` means verbose output.
95 Available subcommands
96 =====================
98 cleanup 
99 -------
101 **New in Django development version**
103 Can be run as a cronjob or directly to clean out old data from the database
104 (only expired sessions at the moment).
106 compilemessages
107 ---------------
109 **New in Django development version**
111 Compiles .po files created with ``makemessages`` to .mo files for use with
112 the builtin gettext support. See :ref:`topics-i18n`.
114 --locale
115 ~~~~~~~~
117 Use the ``--locale`` or ``-l`` option to specify the locale to process.
118 If not provided all locales are processed.
120 Example usage::
122     django-admin.py compilemessages --locale=br_PT
124 createcachetable 
125 ----------------
127 .. django-admin:: createcachetable <tablename>
129 Creates a cache table named ``tablename`` for use with the database cache
130 backend. See :ref:`topics-cache` for more information.
132 createsuperuser
133 ---------------
135 .. django-admin:: createsuperuser 
137 **New in Django development version**
139 Creates a superuser account (a user who has all permissions). This is
140 useful if you need to create an initial superuser account but did not
141 do so during ``syncdb``, or if you need to programmatically generate
142 superuser accounts for your site(s).
144 When run interactively, this command will prompt for a password for
145 the new superuser account. When run non-interactively, no password
146 will be set, and the superuser account will not be able to log in until
147 a password has been manually set for it.
149 .. django-admin-option:: --username
150 .. django-admin-option:: --email
152 The username and e-mail address for the new account can be supplied by
153 using the ``--username`` and ``--email`` arguments on the command
154 line. If either of those is not supplied, ``createsuperuser`` will prompt for
155 it when running interactively.
157 This command is only available if Django's :ref:`authentication system
158 <topics-auth>` (``django.contrib.auth``) is installed.
160 dbshell
161 -------
163 .. django-admin:: dbshell
165 Runs the command-line client for the database engine specified in your
166 ``DATABASE_ENGINE`` setting, with the connection parameters specified in your
167 ``DATABASE_USER``, ``DATABASE_PASSWORD``, etc., settings.
169     * For PostgreSQL, this runs the ``psql`` command-line client.
170     * For MySQL, this runs the ``mysql`` command-line client.
171     * For SQLite, this runs the ``sqlite3`` command-line client.
173 This command assumes the programs are on your ``PATH`` so that a simple call to
174 the program name (``psql``, ``mysql``, ``sqlite3``) will find the program in
175 the right place. There's no way to specify the location of the program
176 manually.
178 diffsettings
179 ------------
181 .. django-admin:: diffsettings
183 Displays differences between the current settings file and Django's default
184 settings. 
186 Settings that don't appear in the defaults are followed by ``"###"``. For
187 example, the default settings don't define ``ROOT_URLCONF``, so
188 ``ROOT_URLCONF`` is followed by ``"###"`` in the output of ``diffsettings``.
190 Note that Django's default settings live in ``django/conf/global_settings.py``,
191 if you're ever curious to see the full list of defaults.
193 dumpdata
194 --------
196 .. django-admin:: dumpdata <appname appname ...>
198 Outputs to standard output all data in the database associated with the named
199 application(s).
201 If no application name is provided, all installed applications will be dumped.
203 The output of ``dumpdata`` can be used as input for ``loaddata``.
205 Note that ``dumpdata`` uses the default manager on the model for selecting the
206 records to dump. If you're using a :ref:`custom manager <custom-managers>` as
207 the default manager and it filters some of the available records, not all of the
208 objects will be dumped.
210 .. django-admin-option:: --exclude
212 **New in Django development version**
214 Exclude a specific application from the applications whose contents is
215 output. For example, to specifically exclude the `auth` application from
216 the output, you would call::
218     django-admin.py dumpdata --exclude=auth
220 If you want to exclude multiple applications, use multiple ``--exclude``
221 directives::
223     django-admin.py dumpdata --exclude=auth --exclude=contenttype
226 .. django-admin-option:: --format <fmt>
228     By default, ``dumpdata`` will format its output in JSON, but you can use the
229     ``--format`` option to specify another format. Currently supported formats
230     are listed in :ref:`serialization-formats`.
232 .. django-admin-option:: --indent <num>
234     By default, ``dumpdata`` will output all data on a single line. This isn't
235     easy for humans to read, so you can use the ``--indent`` option to
236     pretty-print the output with a number of indentation spaces.
238 flush
239 -----
241 .. django-admin: flush
243 Returns the database to the state it was in immediately after syncdb was
244 executed. This means that all data will be removed from the database, any
245 post-synchronization handlers will be re-executed, and the ``initial_data``
246 fixture will be re-installed.
248 The behavior of this command has changed in the Django development version.
249 Previously, this command cleared *every* table in the database, including any
250 table that Django didn't know about (i.e., tables that didn't have associated
251 models and/or weren't in ``INSTALLED_APPS``). Now, the command only clears
252 tables that are represented by Django models and are activated in
253 ``INSTALLED_APPS``.
255 .. django-admin-option:: --noinput
257     Use the ``--noinput`` option to suppress all user prompting, such as "Are
258     you sure?" confirmation messages. This is useful if ``django-admin.py`` is
259     being executed as an unattended, automated script.
261 inspectdb
262 ---------
264 Introspects the database tables in the database pointed-to by the
265 ``DATABASE_NAME`` setting and outputs a Django model module (a ``models.py``
266 file) to standard output.
268 Use this if you have a legacy database with which you'd like to use Django.
269 The script will inspect the database and create a model for each table within
272 As you might expect, the created models will have an attribute for every field
273 in the table. Note that ``inspectdb`` has a few special cases in its field-name
274 output:
276     * If ``inspectdb`` cannot map a column's type to a model field type, it'll
277       use ``TextField`` and will insert the Python comment
278       ``'This field type is a guess.'`` next to the field in the generated
279       model.
281     * If the database column name is a Python reserved word (such as
282       ``'pass'``, ``'class'`` or ``'for'``), ``inspectdb`` will append
283       ``'_field'`` to the attribute name. For example, if a table has a column
284       ``'for'``, the generated model will have a field ``'for_field'``, with
285       the ``db_column`` attribute set to ``'for'``. ``inspectdb`` will insert
286       the Python comment
287       ``'Field renamed because it was a Python reserved word.'`` next to the
288       field.
290 This feature is meant as a shortcut, not as definitive model generation. After
291 you run it, you'll want to look over the generated models yourself to make
292 customizations. In particular, you'll need to rearrange models' order, so that
293 models that refer to other models are ordered properly.
295 Primary keys are automatically introspected for PostgreSQL, MySQL and
296 SQLite, in which case Django puts in the ``primary_key=True`` where
297 needed.
299 ``inspectdb`` works with PostgreSQL, MySQL and SQLite. Foreign-key detection
300 only works in PostgreSQL and with certain types of MySQL tables.
302 loaddata <fixture fixture ...>
303 ------------------------------
305 Searches for and loads the contents of the named fixture into the database.
307 A *fixture* is a collection of files that contain the serialized contents of
308 the database. Each fixture has a unique name, and the files that comprise the
309 fixture can be distributed over multiple directories, in multiple applications.
311 Django will search in three locations for fixtures:
313    1. In the ``fixtures`` directory of every installed application
314    2. In any directory named in the ``FIXTURE_DIRS`` setting
315    3. In the literal path named by the fixture
317 Django will load any and all fixtures it finds in these locations that match
318 the provided fixture names.
320 If the named fixture has a file extension, only fixtures of that type
321 will be loaded. For example::
323     django-admin.py loaddata mydata.json
325 would only load JSON fixtures called ``mydata``. The fixture extension
326 must correspond to the registered name of a serializer (e.g., ``json`` or
327 ``xml``).
329 If you omit the extension, Django will search all available fixture types
330 for a matching fixture. For example::
332     django-admin.py loaddata mydata
334 would look for any fixture of any fixture type called ``mydata``. If a fixture
335 directory contained ``mydata.json``, that fixture would be loaded
336 as a JSON fixture. However, if two fixtures with the same name but different
337 fixture type are discovered (for example, if ``mydata.json`` and
338 ``mydata.xml`` were found in the same fixture directory), fixture
339 installation will be aborted, and any data installed in the call to
340 ``loaddata`` will be removed from the database.
342 The fixtures that are named can include directory components. These
343 directories will be included in the search path. For example::
345     django-admin.py loaddata foo/bar/mydata.json
347 would search ``<appname>/fixtures/foo/bar/mydata.json`` for each installed
348 application,  ``<dirname>/foo/bar/mydata.json`` for each directory in
349 ``FIXTURE_DIRS``, and the literal path ``foo/bar/mydata.json``.
351 Note that the order in which fixture files are processed is undefined. However,
352 all fixture data is installed as a single transaction, so data in
353 one fixture can reference data in another fixture. If the database backend
354 supports row-level constraints, these constraints will be checked at the
355 end of the transaction.
357 The ``dumpdata`` command can be used to generate input for ``loaddata``.
359 .. admonition:: MySQL and Fixtures
361     Unfortunately, MySQL isn't capable of completely supporting all the
362     features of Django fixtures. If you use MyISAM tables, MySQL doesn't
363     support transactions or constraints, so you won't get a rollback if
364     multiple transaction files are found, or validation of fixture data.
365     If you use InnoDB tables, you won't be able to have any forward
366     references in your data files - MySQL doesn't provide a mechanism to
367     defer checking of row constraints until a transaction is committed.
369 --verbosity
370 ~~~~~~~~~~~
372 Use ``--verbosity`` to specify the amount of notification and debug information
373 that ``django-admin.py`` should print to the console.
375         * ``0`` means no output.
376         * ``1`` means normal output (default).
377         * ``2`` means verbose output.
379 Example usage::
381     django-admin.py loaddata --verbosity=2
383 makemessages
384 ------------
386 **New in Django development version**
388 Runs over the entire source tree of the current directory and pulls out all
389 strings marked for translation. It creates (or updates) a message file in the
390 conf/locale (in the django tree) or locale (for project and application)
391 directory. After making changes to the messages files you need to compile them
392 with ``compilemessages`` for use with the builtin gettext support. See the
393 :ref:`i18n documentation <how-to-create-language-files>` for details.
395 --all
396 ~~~~~
398 Use the ``--all`` or ``-a`` option to update the message files for all
399 available languages.
401 Example usage::
403     django-admin.py makemessages --all
405 --extension
406 ~~~~~~~~~~~
408 Use the ``--extension`` or ``-e`` option to specify a list of file extensions
409 to examine (default: ".html").
411 Example usage::
413     django-admin.py makemessages --locale=de --extension xhtml
415 Separate multiple extensions with commas or use -e or --extension multiple times::
417     django-admin.py makemessages --locale=de --extension=html,txt --extension xml
419 --locale
420 ~~~~~~~~
422 Use the ``--locale`` or ``-l`` option to specify the locale to process.
424 Example usage::
426     django-admin.py makemessages --locale=br_PT
428 --domain
429 ~~~~~~~~
431 Use the ``--domain`` or ``-d`` option to change the domain of the messages files.
432 Currently supported:
434         * ``django`` for all ``*.py`` and ``*.html`` files (default) 
435         * ``djangojs`` for ``*.js`` files
437 --verbosity
438 ~~~~~~~~~~~
440 Use ``--verbosity`` or ``-v`` to specify the amount of notification and debug
441 information that ``django-admin.py`` should print to the console.
443         * ``0`` means no output.
444         * ``1`` means normal output (default).
445         * ``2`` means verbose output.
447 Example usage::
449     django-admin.py makemessages --verbosity=2
451 reset <appname appname ...>
452 ---------------------------
454 Executes the equivalent of ``sqlreset`` for the given app name(s).
456 --noinput
457 ~~~~~~~~~
459 Use the ``--noinput`` option to suppress all user prompting, such as
460 "Are you sure?" confirmation messages. This is useful if ``django-admin.py``
461 is being executed as an unattended, automated script.
463 runfcgi [options]
464 -----------------
466 Starts a set of FastCGI processes suitable for use with any Web server that
467 supports the FastCGI protocol. See the :ref:`FastCGI deployment documentation
468 <howto-deployment-fastcgi>` for details. Requires the Python FastCGI module from
469 `flup`_.
471 .. _flup: http://www.saddi.com/software/flup/
473 runserver [optional port number, or ipaddr:port]
474 ------------------------------------------------
476 Starts a lightweight development Web server on the local machine. By default,
477 the server runs on port 8000 on the IP address 127.0.0.1. You can pass in an
478 IP address and port number explicitly.
480 If you run this script as a user with normal privileges (recommended), you
481 might not have access to start a port on a low port number. Low port numbers
482 are reserved for the superuser (root).
484 DO NOT USE THIS SERVER IN A PRODUCTION SETTING. It has not gone through
485 security audits or performance tests. (And that's how it's gonna stay. We're in
486 the business of making Web frameworks, not Web servers, so improving this
487 server to be able to handle a production environment is outside the scope of
488 Django.)
490 The development server automatically reloads Python code for each request, as
491 needed. You don't need to restart the server for code changes to take effect.
493 When you start the server, and each time you change Python code while the
494 server is running, the server will validate all of your installed models. (See
495 the ``validate`` command below.) If the validator finds errors, it will print
496 them to standard output, but it won't stop the server.
498 You can run as many servers as you want, as long as they're on separate ports.
499 Just execute ``django-admin.py runserver`` more than once.
501 Note that the default IP address, 127.0.0.1, is not accessible from other
502 machines on your network. To make your development server viewable to other
503 machines on the network, use its own IP address (e.g. ``192.168.2.1``) or
504 ``0.0.0.0``.
506 --adminmedia
507 ~~~~~~~~~~~~
509 Use the ``--adminmedia`` option to tell Django where to find the various CSS
510 and JavaScript files for the Django admin interface. Normally, the development
511 server serves these files out of the Django source tree magically, but you'd
512 want to use this if you made any changes to those files for your own site.
514 Example usage::
516     django-admin.py runserver --adminmedia=/tmp/new-admin-style/
518 --noreload
519 ~~~~~~~~~~
521 Use the ``--noreload`` option to disable the use of the auto-reloader. This
522 means any Python code changes you make while the server is running will *not*
523 take effect if the particular Python modules have already been loaded into
524 memory.
526 Example usage::
528     django-admin.py runserver --noreload
530 Examples of using different ports and addresses
531 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
533 Port 8000 on IP address 127.0.0.1::
535         django-admin.py runserver
537 Port 8000 on IP address 1.2.3.4::
539         django-admin.py runserver 1.2.3.4:8000
541 Port 7000 on IP address 127.0.0.1::
543     django-admin.py runserver 7000
545 Port 7000 on IP address 1.2.3.4::
547     django-admin.py runserver 1.2.3.4:7000
549 Serving static files with the development server
550 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
552 By default, the development server doesn't serve any static files for your site
553 (such as CSS files, images, things under ``MEDIA_URL`` and so forth). If
554 you want to configure Django to serve static media, read :ref:`howto-static-files`.
556 Turning off auto-reload
557 ~~~~~~~~~~~~~~~~~~~~~~~
559 To disable auto-reloading of code while the development server is running, use the
560 ``--noreload`` option, like so::
562     django-admin.py runserver --noreload
564 shell
565 -----
567 Starts the Python interactive interpreter.
569 Django will use IPython_, if it's installed. If you have IPython installed and
570 want to force use of the "plain" Python interpreter, use the ``--plain``
571 option, like so::
573     django-admin.py shell --plain
575 .. _IPython: http://ipython.scipy.org/
577 sql <appname appname ...>
578 -------------------------
580 Prints the CREATE TABLE SQL statements for the given app name(s).
582 sqlall <appname appname ...>
583 ----------------------------
585 Prints the CREATE TABLE and initial-data SQL statements for the given app name(s).
587 Refer to the description of ``sqlcustom`` for an explanation of how to
588 specify initial data.
590 sqlclear <appname appname ...>
591 ------------------------------
593 Prints the DROP TABLE SQL statements for the given app name(s).
595 sqlcustom <appname appname ...>
596 -------------------------------
598 Prints the custom SQL statements for the given app name(s).
600 For each model in each specified app, this command looks for the file
601 ``<appname>/sql/<modelname>.sql``, where ``<appname>`` is the given app name and
602 ``<modelname>`` is the model's name in lowercase. For example, if you have an
603 app ``news`` that includes a ``Story`` model, ``sqlcustom`` will attempt
604 to read a file ``news/sql/story.sql`` and append it to the output of this
605 command.
607 Each of the SQL files, if given, is expected to contain valid SQL. The SQL
608 files are piped directly into the database after all of the models'
609 table-creation statements have been executed. Use this SQL hook to make any
610 table modifications, or insert any SQL functions into the database.
612 Note that the order in which the SQL files are processed is undefined.
614 sqlflush
615 --------
617 Prints the SQL statements that would be executed for the `flush`_ command.
619 sqlindexes <appname appname ...>
620 --------------------------------
622 Prints the CREATE INDEX SQL statements for the given app name(s).
624 sqlreset <appname appname ...>
625 ------------------------------
627 Prints the DROP TABLE SQL, then the CREATE TABLE SQL, for the given app name(s).
629 sqlsequencereset <appname appname ...>
630 --------------------------------------
632 Prints the SQL statements for resetting sequences for the given app name(s).
634 See http://simon.incutio.com/archive/2004/04/21/postgres for more information.
636 startapp <appname>
637 ------------------
639 Creates a Django app directory structure for the given app name in the current
640 directory.
642 startproject <projectname>
643 --------------------------
645 Creates a Django project directory structure for the given project name in the
646 current directory.
648 This command is disabled when the ``--settings`` option to
649 ``django-admin.py`` is used, or when the environment variable
650 ``DJANGO_SETTINGS_MODULE`` has been set. To re-enable it in these
651 situations, either omit the ``--settings`` option or unset
652 ``DJANGO_SETTINGS_MODULE``.
654 syncdb
655 ------
657 Creates the database tables for all apps in ``INSTALLED_APPS`` whose tables
658 have not already been created.
660 Use this command when you've added new applications to your project and want to
661 install them in the database. This includes any apps shipped with Django that
662 might be in ``INSTALLED_APPS`` by default. When you start a new project, run
663 this command to install the default apps.
665 .. admonition:: Syncdb will not alter existing tables
667    ``syncdb`` will only create tables for models which have not yet been
668    installed. It will *never* issue ``ALTER TABLE`` statements to match
669    changes made to a model class after installation. Changes to model classes
670    and database schemas often involve some form of ambiguity and, in those
671    cases, Django would have to guess at the correct changes to make. There is
672    a risk that critical data would be lost in the process.
674    If you have made changes to a model and wish to alter the database tables
675    to match, use the ``sql`` command to display the new SQL structure and
676    compare that to your existing table schema to work out the changes.
678 If you're installing the ``django.contrib.auth`` application, ``syncdb`` will
679 give you the option of creating a superuser immediately.
681 ``syncdb`` will also search for and install any fixture named ``initial_data``
682 with an appropriate extension (e.g. ``json`` or ``xml``). See the
683 documentation for ``loaddata`` for details on the specification of fixture
684 data files.
686 --verbosity
687 ~~~~~~~~~~~
689 Use ``--verbosity`` to specify the amount of notification and debug information
690 that ``django-admin.py`` should print to the console.
692         * ``0`` means no output.
693         * ``1`` means normal output (default).
694         * ``2`` means verbose output.
696 Example usage::
698     django-admin.py syncdb --verbosity=2
700 --noinput
701 ~~~~~~~~~
703 Use the ``--noinput`` option to suppress all user prompting, such as
704 "Are you sure?" confirmation messages. This is useful if ``django-admin.py``
705 is being executed as an unattended, automated script.
707 test
708 ----
710 Runs tests for all installed models. See :ref:`topics-testing` for more
711 information.
713 --noinput
714 ~~~~~~~~~
716 Use the ``--noinput`` option to suppress all user prompting, such as
717 "Are you sure?" confirmation messages. This is useful if ``django-admin.py``
718 is being executed as an unattended, automated script.
720 --verbosity
721 ~~~~~~~~~~~
723 Use ``--verbosity`` to specify the amount of notification and debug information
724 that ``django-admin.py`` should print to the console.
726         * ``0`` means no output.
727         * ``1`` means normal output (default).
728         * ``2`` means verbose output.
730 Example usage::
732     django-admin.py test --verbosity=2
734 testserver <fixture fixture ...>
735 --------------------------------
737 **New in Django development version**
739 Runs a Django development server (as in ``runserver``) using data from the
740 given fixture(s).
742 For example, this command::
744     django-admin.py testserver mydata.json
746 ...would perform the following steps:
748     1. Create a test database, as described in :ref:`topics-testing`.
749     2. Populate the test database with fixture data from the given fixtures.
750        (For more on fixtures, see the documentation for ``loaddata`` above.)
751     3. Runs the Django development server (as in ``runserver``), pointed at
752        this newly created test database instead of your production database.
754 This is useful in a number of ways:
756     * When you're writing :ref:`unit tests <topics-testing>` of how your views
757       act with certain fixture data, you can use ``testserver`` to interact with
758       the views in a Web browser, manually.
760     * Let's say you're developing your Django application and have a "pristine"
761       copy of a database that you'd like to interact with. You can dump your
762       database to a fixture (using the ``dumpdata`` command, explained above),
763       then use ``testserver`` to run your Web application with that data. With
764       this arrangement, you have the flexibility of messing up your data
765       in any way, knowing that whatever data changes you're making are only
766       being made to a test database.
768 Note that this server does *not* automatically detect changes to your Python
769 source code (as ``runserver`` does). It does, however, detect changes to
770 templates.
772 --addrport [port number or ipaddr:port]
773 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
775 Use ``--addrport`` to specify a different port, or IP address and port, from
776 the default of 127.0.0.1:8000. This value follows exactly the same format and
777 serves exactly the same function as the argument to the ``runserver`` subcommand.
779 Examples:
781 To run the test server on port 7000 with ``fixture1`` and ``fixture2``::
783     django-admin.py testserver --addrport 7000 fixture1 fixture2
784     django-admin.py testserver fixture1 fixture2 --addrport 7000
786 (The above statements are equivalent. We include both of them to demonstrate
787 that it doesn't matter whether the options come before or after the fixture
788 arguments.)
790 To run on 1.2.3.4:7000 with a ``test`` fixture::
792     django-admin.py testserver --addrport 1.2.3.4:7000 test
794 --verbosity
795 ~~~~~~~~~~~
797 Use ``--verbosity`` to specify the amount of notification and debug information
798 that ``django-admin.py`` should print to the console.
800         * ``0`` means no output.
801         * ``1`` means normal output (default).
802         * ``2`` means verbose output.
804 Example usage::
806     django-admin.py testserver --verbosity=2
808 validate
809 --------
811 Validates all installed models (according to the ``INSTALLED_APPS`` setting)
812 and prints validation errors to standard output.
814 Default options
815 ===============
817 Although some subcommands may allow their own custom options, every subcommand
818 allows for the following options:
820 --pythonpath
821 ------------
823 Example usage::
825     django-admin.py syncdb --pythonpath='/home/djangoprojects/myproject'
827 Adds the given filesystem path to the Python `import search path`_. If this
828 isn't provided, ``django-admin.py`` will use the ``PYTHONPATH`` environment
829 variable.
831 Note that this option is unnecessary in ``manage.py``, because it takes care of
832 setting the Python path for you.
834 .. _import search path: http://diveintopython.org/getting_to_know_python/everything_is_an_object.html
836 --settings
837 ----------
839 Example usage::
841     django-admin.py syncdb --settings=mysite.settings
843 Explicitly specifies the settings module to use. The settings module should be
844 in Python package syntax, e.g. ``mysite.settings``. If this isn't provided,
845 ``django-admin.py`` will use the ``DJANGO_SETTINGS_MODULE`` environment
846 variable.
848 Note that this option is unnecessary in ``manage.py``, because it uses
849 ``settings.py`` from the current project by default.
851 --traceback
852 -----------
854 Example usage::
856     django-admin.py syncdb --traceback
858 By default, ``django-admin.py`` will show a simple error message whenever an
859 error occurs. If you specify ``--traceback``, ``django-admin.py``  will
860 output a full stack trace whenever an exception is raised.
862 Extra niceties
863 ==============
865 Syntax coloring
866 ---------------
868 The ``django-admin.py`` / ``manage.py`` commands that output SQL to standard
869 output will use pretty color-coded output if your terminal supports
870 ANSI-colored output. It won't use the color codes if you're piping the
871 command's output to another program.
873 Bash completion
874 ---------------
876 If you use the Bash shell, consider installing the Django bash completion
877 script, which lives in ``extras/django_bash_completion`` in the Django
878 distribution. It enables tab-completion of ``django-admin.py`` and
879 ``manage.py`` commands, so you can, for instance...
881     * Type ``django-admin.py``.
882     * Press [TAB] to see all available options.
883     * Type ``sql``, then [TAB], to see all available options whose names start
884       with ``sql``.
888 See :ref:`howto-custom-management-commands` for how to add customized actions.