Django

Code

root/django/trunk/docs/django-admin.txt

Revision 7294, 26.5 kB (checked in by mtredinnick, 2 months ago)

Added "svn:eol-style native" to every text file in the tree (*.txt, *.html,
*.py, *.xml and AUTHORS, etc). Added "svn:ignore *.pyc" to some directories in
tests/regressiontests/ that were previously missing it.

Fixed #6545, #6801.

  • Property svn:eol-style set to native
Line 
1 =============================
2 django-admin.py and manage.py
3 =============================
4
5 ``django-admin.py`` is Django's command-line utility for administrative tasks.
6 This document outlines all it can do.
7
8 In addition, ``manage.py`` is automatically created in each Django project.
9 ``manage.py`` is a thin wrapper around ``django-admin.py`` that takes care of
10 two things for you before delegating to ``django-admin.py``:
11
12     * It puts your project's package on ``sys.path``.
13
14     * It sets the ``DJANGO_SETTINGS_MODULE`` environment variable so that it
15       points to your project's ``settings.py`` file.
16
17 The ``django-admin.py`` script should be on your system path if you installed
18 Django via its ``setup.py`` utility. If it's not on your path, you can find it in
19 ``site-packages/django/bin`` within your Python installation. Consider
20 symlinking it from some place on your path, such as ``/usr/local/bin``.
21
22 For Windows users, who do not have symlinking functionality available, you
23 can copy ``django-admin.py`` to a location on your existing path or edit the
24 ``PATH`` settings (under ``Settings - Control Panel - System - Advanced - Environment...``)
25 to point to its installed location.
26
27 Generally, when working on a single Django project, it's easier to use
28 ``manage.py``. Use ``django-admin.py`` with ``DJANGO_SETTINGS_MODULE``, or the
29 ``--settings`` command line option, if you need to switch between multiple
30 Django settings files.
31
32 The command-line examples throughout this document use ``django-admin.py`` to
33 be consistent, but any example can use ``manage.py`` just as well.
34
35 Usage
36 =====
37
38 ``django-admin.py <subcommand> [options]``
39
40 ``manage.py <subcommand> [options]``
41
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.
45
46 Getting runtime help
47 --------------------
48
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.
51
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
55 options.
56
57 App names
58 ---------
59
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``.
63
64 Determining the version
65 -----------------------
66
67 Run ``django-admin.py --version`` to display the current Django version.
68
69 Examples of output::
70
71         0.95
72     0.96
73     0.97-pre-SVN-6069
74
75 Available subcommands
76 =====================
77
78 adminindex <appname appname ...>
79 --------------------------------
80
81 Prints the admin-index template snippet for the given app name(s).
82
83 Use admin-index template snippets if you want to customize the look and feel of
84 your admin's index page. See `Tutorial 2`_ for more information.
85
86 .. _Tutorial 2: ../tutorial02/
87
88 createcachetable <tablename>
89 ----------------------------
90
91 Creates a cache table named ``tablename`` for use with the database cache
92 backend. See the `cache documentation`_ for more information.
93
94 .. _cache documentation: ../cache/
95
96 dbshell
97 -------
98
99 Runs the command-line client for the database engine specified in your
100 ``DATABASE_ENGINE`` setting, with the connection parameters specified in your
101 ``DATABASE_USER``, ``DATABASE_PASSWORD``, etc., settings.
102
103     * For PostgreSQL, this runs the ``psql`` command-line client.
104     * For MySQL, this runs the ``mysql`` command-line client.
105     * For SQLite, this runs the ``sqlite3`` command-line client.
106
107 This command assumes the programs are on your ``PATH`` so that a simple call to
108 the program name (``psql``, ``mysql``, ``sqlite3``) will find the program in
109 the right place. There's no way to specify the location of the program
110 manually.
111
112 diffsettings
113 ------------
114
115 Displays differences between the current settings file and Django's default
116 settings.
117
118 Settings that don't appear in the defaults are followed by ``"###"``. For
119 example, the default settings don't define ``ROOT_URLCONF``, so
120 ``ROOT_URLCONF`` is followed by ``"###"`` in the output of ``diffsettings``.
121
122 Note that Django's default settings live in ``django/conf/global_settings.py``,
123 if you're ever curious to see the full list of defaults.
124
125 dumpdata <appname appname ...>
126 ------------------------------
127
128 Outputs to standard output all data in the database associated with the named
129 application(s).
130
131 If no application name is provided, all installed applications will be dumped.
132
133 The output of ``dumpdata`` can be used as input for ``loaddata``.
134
135 Note that ``dumpdata`` uses the default manager on the model for selecting the
136 records to dump. If you're using a `custom manager`_ as the default manager
137 and it filters some of the available records, not all of the objects will be
138 dumped.
139
140 .. _custom manager: ../model-api/#custom-managers
141
142 --format
143 ~~~~~~~~
144
145 By default, ``dumpdata`` will format its output in JSON, but you can use the
146 ``--format`` option to specify another format. Currently supported formats are
147 listed in `Serialization formats`_.
148
149 Example usage::
150
151     django-admin.py dumpdata --format=xml
152
153 .. _Serialization formats: ../serialization/#serialization-formats
154
155 --indent
156 ~~~~~~~~
157
158 By default, ``dumpdata`` will output all data on a single line. This isn't easy
159 for humans to read, so you can use the ``--indent`` option to pretty-print the
160 output with a number of indentation spaces.
161
162 Example usage::
163
164     django-admin.py dumpdata --indent=4
165
166 flush
167 -----
168
169 Returns the database to the state it was in immediately after syncdb was
170 executed. This means that all data will be removed from the database, any
171 post-synchronization handlers will be re-executed, and the ``initial_data``
172 fixture will be re-installed.
173
174 The behavior of this command has changed in the Django development version.
175 Previously, this command cleared *every* table in the database, including any
176 table that Django didn't know about (i.e., tables that didn't have associated
177 models and/or weren't in ``INSTALLED_APPS``). Now, the command only clears
178 tables that are represented by Django models and are activated in
179 ``INSTALLED_APPS``.
180
181 --noinput
182 ~~~~~~~~~
183
184 Use the ``--noinput`` option to suppress all user prompting, such as
185 "Are you sure?" confirmation messages. This is useful if ``django-admin.py``
186 is being executed as an unattended, automated script.
187
188 --verbosity
189 ~~~~~~~~~~~
190
191 Use ``--verbosity`` to specify the amount of notification and debug information
192 that ``django-admin.py`` should print to the console.
193
194         * ``0`` means no output.
195         * ``1`` means normal output (default).
196         * ``2`` means verbose output.
197
198 Example usage::
199
200     django-admin.py flush --verbosity=2
201
202 inspectdb
203 ---------
204
205 Introspects the database tables in the database pointed-to by the
206 ``DATABASE_NAME`` setting and outputs a Django model module (a ``models.py``
207 file) to standard output.
208
209 Use this if you have a legacy database with which you'd like to use Django.
210 The script will inspect the database and create a model for each table within
211 it.
212
213 As you might expect, the created models will have an attribute for every field
214 in the table. Note that ``inspectdb`` has a few special cases in its field-name
215 output:
216
217     * If ``inspectdb`` cannot map a column's type to a model field type, it'll
218       use ``TextField`` and will insert the Python comment
219       ``'This field type is a guess.'`` next to the field in the generated
220       model.
221
222     * If the database column name is a Python reserved word (such as
223       ``'pass'``, ``'class'`` or ``'for'``), ``inspectdb`` will append
224       ``'_field'`` to the attribute name. For example, if a table has a column
225       ``'for'``, the generated model will have a field ``'for_field'``, with
226       the ``db_column`` attribute set to ``'for'``. ``inspectdb`` will insert
227       the Python comment
228       ``'Field renamed because it was a Python reserved word.'`` next to the
229       field.
230
231 This feature is meant as a shortcut, not as definitive model generation. After
232 you run it, you'll want to look over the generated models yourself to make
233 customizations. In particular, you'll need to rearrange models' order, so that
234 models that refer to other models are ordered properly.
235
236 Primary keys are automatically introspected for PostgreSQL, MySQL and
237 SQLite, in which case Django puts in the ``primary_key=True`` where
238 needed.
239
240 ``inspectdb`` works with PostgreSQL, MySQL and SQLite. Foreign-key detection
241 only works in PostgreSQL and with certain types of MySQL tables.
242
243 loaddata <fixture fixture ...>
244 ------------------------------
245
246 Searches for and loads the contents of the named fixture into the database.
247
248 A *fixture* is a collection of files that contain the serialized contents of
249 the database. Each fixture has a unique name, and the files that comprise the
250 fixture can be distributed over multiple directories, in multiple applications.
251
252 Django will search in three locations for fixtures:
253
254    1. In the ``fixtures`` directory of every installed application
255    2. In any directory named in the ``FIXTURE_DIRS`` setting
256    3. In the literal path named by the fixture
257
258 Django will load any and all fixtures it finds in these locations that match
259 the provided fixture names.
260
261 If the named fixture has a file extension, only fixtures of that type
262 will be loaded. For example::
263
264     django-admin.py loaddata mydata.json
265
266 would only load JSON fixtures called ``mydata``. The fixture extension
267 must correspond to the registered name of a serializer (e.g., ``json`` or
268 ``xml``).
269
270 If you omit the extension, Django will search all available fixture types
271 for a matching fixture. For example::
272
273     django-admin.py loaddata mydata
274
275 would look for any fixture of any fixture type called ``mydata``. If a fixture
276 directory contained ``mydata.json``, that fixture would be loaded
277 as a JSON fixture. However, if two fixtures with the same name but different
278 fixture type are discovered (for example, if ``mydata.json`` and
279 ``mydata.xml`` were found in the same fixture directory), fixture
280 installation will be aborted, and any data installed in the call to
281 ``loaddata`` will be removed from the database.
282
283 The fixtures that are named can include directory components. These
284 directories will be included in the search path. For example::
285
286     django-admin.py loaddata foo/bar/mydata.json
287
288 would search ``<appname>/fixtures/foo/bar/mydata.json`` for each installed
289 application,  ``<dirname>/foo/bar/mydata.json`` for each directory in
290 ``FIXTURE_DIRS``, and the literal path ``foo/bar/mydata.json``.
291
292 Note that the order in which fixture files are processed is undefined. However,
293 all fixture data is installed as a single transaction, so data in
294 one fixture can reference data in another fixture. If the database backend
295 supports row-level constraints, these constraints will be checked at the
296 end of the transaction.
297
298 The ``dumpdata`` command can be used to generate input for ``loaddata``.
299
300 .. admonition:: MySQL and Fixtures
301
302     Unfortunately, MySQL isn't capable of completely supporting all the
303     features of Django fixtures. If you use MyISAM tables, MySQL doesn't
304     support transactions or constraints, so you won't get a rollback if
305     multiple transaction files are found, or validation of fixture data.
306     If you use InnoDB tables, you won't be able to have any forward
307     references in your data files - MySQL doesn't provide a mechanism to
308     defer checking of row constraints until a transaction is committed.
309
310 --verbosity
311 ~~~~~~~~~~~
312
313 Use ``--verbosity`` to specify the amount of notification and debug information
314 that ``django-admin.py`` should print to the console.
315
316         * ``0`` means no input.
317         * ``1`` means normal input (default).
318         * ``2`` means verbose input.
319
320 Example usage::
321
322     django-admin.py loaddata --verbosity=2
323
324 reset <appname appname ...>
325 ---------------------------
326
327 Executes the equivalent of ``sqlreset`` for the given app name(s).
328
329 --noinput
330 ~~~~~~~~~
331
332 Use the ``--noinput`` option to suppress all user prompting, such as
333 "Are you sure?" confirmation messages. This is useful if ``django-admin.py``
334 is being executed as an unattended, automated script.
335
336 runfcgi [options]
337 -----------------
338
339 Starts a set of FastCGI processes suitable for use with any Web server
340 that supports the FastCGI protocol. See the `FastCGI deployment
341 documentation`_ for details. Requires the Python FastCGI module from
342 `flup`_.
343
344 .. _FastCGI deployment documentation: ../fastcgi/
345 .. _flup: http://www.saddi.com/software/flup/
346
347 runserver [optional port number, or ipaddr:port]
348 ------------------------------------------------
349
350 Starts a lightweight development Web server on the local machine. By default,
351 the server runs on port 8000 on the IP address 127.0.0.1. You can pass in an
352 IP address and port number explicitly.
353
354 If you run this script as a user with normal privileges (recommended), you
355 might not have access to start a port on a low port number. Low port numbers
356 are reserved for the superuser (root).
357
358 DO NOT USE THIS SERVER IN A PRODUCTION SETTING. It has not gone through
359 security audits or performance tests. (And that's how it's gonna stay. We're in
360 the business of making Web frameworks, not Web servers, so improving this
361 server to be able to handle a production environment is outside the scope of
362 Django.)
363
364 The development server automatically reloads Python code for each request, as
365 needed. You don't need to restart the server for code changes to take effect.
366
367 When you start the server, and each time you change Python code while the
368 server is running, the server will validate all of your installed models. (See
369 the ``validate`` command below.) If the validator finds errors, it will print
370 them to standard output, but it won't stop the server.
371
372 You can run as many servers as you want, as long as they're on separate ports.
373 Just execute ``django-admin.py runserver`` more than once.
374
375 Note that the default IP address, 127.0.0.1, is not accessible from other
376 machines on your network. To make your development server viewable to other
377 machines on the network, use its own IP address (e.g. ``192.168.2.1``) or
378 ``0.0.0.0``.
379
380 --adminmedia
381 ~~~~~~~~~~~~
382
383 Use the ``--adminmedia`` option to tell Django where to find the various CSS
384 and JavaScript files for the Django admin interface. Normally, the development
385 server serves these files out of the Django source tree magically, but you'd
386 want to use this if you made any changes to those files for your own site.
387
388 Example usage::
389
390     django-admin.py runserver --adminmedia=/tmp/new-admin-style/
391
392 --noreload
393 ~~~~~~~~~~
394
395 Use the ``--noreload`` option to disable the use of the auto-reloader. This
396 means any Python code changes you make while the server is running will *not*
397 take effect if the particular Python modules have already been loaded into
398 memory.
399
400 Examples of using different ports and addresses
401 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
402
403 Port 8000 on IP address 127.0.0.1::
404
405         django-admin.py runserver
406
407 Port 8000 on IP address 1.2.3.4::
408
409         django-admin.py runserver 1.2.3.4:8000
410
411 Port 7000 on IP address 127.0.0.1::
412
413     django-admin.py runserver 7000
414
415 Port 7000 on IP address 1.2.3.4::
416
417     django-admin.py runserver 1.2.3.4:7000
418
419 Serving static files with the development server
420 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
421
422 By default, the development server doesn't serve any static files for your site
423 (such as CSS files, images, things under ``MEDIA_URL`` and so forth). If
424 you want to configure Django to serve static media, read the `serving static files`_
425 documentation.
426
427 .. _serving static files: ../static_files/
428
429 Turning off auto-reload
430 ~~~~~~~~~~~~~~~~~~~~~~~
431
432 To disable auto-reloading of code while the development server is running, use the
433 ``--noreload`` option, like so::
434
435     django-admin.py runserver --noreload
436
437 shell
438 -----
439
440 Starts the Python interactive interpreter.
441
442 Django will use IPython_, if it's installed. If you have IPython installed and
443 want to force use of the "plain" Python interpreter, use the ``--plain``
444 option, like so::
445
446     django-admin.py shell --plain
447
448 .. _IPython: http://ipython.scipy.org/
449
450 sql <appname appname ...>
451 -------------------------
452
453 Prints the CREATE TABLE SQL statements for the given app name(s).
454
455 sqlall <appname appname ...>
456 ----------------------------
457
458 Prints the CREATE TABLE and initial-data SQL statements for the given app name(s).
459
460 Refer to the description of ``sqlcustom`` for an explanation of how to
461 specify initial data.
462
463 sqlclear <appname appname ...>
464 ------------------------------
465
466 Prints the DROP TABLE SQL statements for the given app name(s).
467
468 sqlcustom <appname appname ...>
469 -------------------------------
470
471 Prints the custom SQL statements for the given app name(s).
472
473 For each model in each specified app, this command looks for the file
474 ``<appname>/sql/<modelname>.sql``, where ``<appname>`` is the given app name and
475 ``<modelname>`` is the model's name in lowercase. For example, if you have an
476 app ``news`` that includes a ``Story`` model, ``sqlcustom`` will attempt
477 to read a file ``news/sql/story.sql`` and append it to the output of this
478 command.
479
480 Each of the SQL files, if given, is expected to contain valid SQL. The SQL
481 files are piped directly into the database after all of the models'
482 table-creation statements have been executed. Use this SQL hook to make any
483 table modifications, or insert any SQL functions into the database.
484
485 Note that the order in which the SQL files are processed is undefined.
486
487 sqlflush
488 --------
489
490 Prints the SQL statements that would be executed for the `flush`_ command.
491
492 sqlindexes <appname appname ...>
493 --------------------------------
494
495 Prints the CREATE INDEX SQL statements for the given app name(s).
496
497 sqlreset <appname appname ...>
498 ------------------------------
499
500 Prints the DROP TABLE SQL, then the CREATE TABLE SQL, for the given app name(s).
501
502 sqlsequencereset <appname appname ...>
503 --------------------------------------
504
505 Prints the SQL statements for resetting sequences for the given app name(s).
506
507 See http://simon.incutio.com/archive/2004/04/21/postgres for more information.
508
509 startapp <appname>
510 ------------------
511
512 Creates a Django app directory structure for the given app name in the current
513 directory.
514
515 startproject <projectname>
516 --------------------------
517
518 Creates a Django project directory structure for the given project name in the
519 current directory.
520
521 syncdb
522 ------
523
524 Creates the database tables for all apps in ``INSTALLED_APPS`` whose tables
525 have not already been created.
526
527 Use this command when you've added new applications to your project and want to
528 install them in the database. This includes any apps shipped with Django that
529 might be in ``INSTALLED_APPS`` by default. When you start a new project, run
530 this command to install the default apps.
531
532 .. admonition:: Syncdb will not alter existing tables
533
534    ``syncdb`` will only create tables for models which have not yet been
535    installed. It will *never* issue ``ALTER TABLE`` statements to match
536    changes made to a model class after installation. Changes to model classes
537    and database schemas often involve some form of ambiguity and, in those
538    cases, Django would have to guess at the correct changes to make. There is
539    a risk that critical data would be lost in the process.
540
541    If you have made changes to a model and wish to alter the database tables
542    to match, use the ``sql`` command to display the new SQL structure and
543    compare that to your existing table schema to work out the changes.
544
545 If you're installing the ``django.contrib.auth`` application, ``syncdb`` will
546 give you the option of creating a superuser immediately.
547
548 ``syncdb`` will also search for and install any fixture named ``initial_data``
549 with an appropriate extension (e.g. ``json`` or ``xml``). See the
550 documentation for ``loaddata`` for details on the specification of fixture
551 data files.
552
553 --verbosity
554 ~~~~~~~~~~~
555
556 Use ``--verbosity`` to specify the amount of notification and debug information
557 that ``django-admin.py`` should print to the console.
558
559         * ``0`` means no input.
560         * ``1`` means normal input (default).
561         * ``2`` means verbose input.
562
563 Example usage::
564
565     django-admin.py syncdb --verbosity=2
566
567 --noinput
568 ~~~~~~~~~
569
570 Use the ``--noinput`` option to suppress all user prompting, such as
571 "Are you sure?" confirmation messages. This is useful if ``django-admin.py``
572 is being executed as an unattended, automated script.
573
574 test
575 ----
576
577 Runs tests for all installed models.  See `Testing Django applications`_
578 for more information.
579
580 .. _testing Django applications: ../testing/
581
582 --noinput
583 ~~~~~~~~~
584
585 Use the ``--noinput`` option to suppress all user prompting, such as
586 "Are you sure?" confirmation messages. This is useful if ``django-admin.py``
587 is being executed as an unattended, automated script.
588
589 --verbosity
590 ~~~~~~~~~~~
591
592 Use ``--verbosity`` to specify the amount of notification and debug information
593 that ``django-admin.py`` should print to the console.
594
595         * ``0`` means no input.
596         * ``1`` means normal input (default).
597         * ``2`` means verbose input.
598
599 Example usage::
600
601     django-admin.py test --verbosity=2
602
603 testserver <fixture fixture ...>
604 --------------------------------
605
606 **New in Django development version**
607
608 Runs a Django development server (as in ``runserver``) using data from the
609 given fixture(s).
610
611 For example, this command::
612
613     django-admin.py testserver mydata.json
614
615 ...would perform the following steps:
616
617     1. Create a test database, as described in `testing Django applications`_.
618     2. Populate the test database with fixture data from the given fixtures.
619        (For more on fixtures, see the documentation for ``loaddata`` above.)
620     3. Runs the Django development server (as in ``runserver``), pointed at
621        this newly created test database instead of your production database.
622
623 This is useful in a number of ways:
624
625     * When you're writing `unit tests`_ of how your views act with certain
626       fixture data, you can use ``testserver`` to interact with the views in
627       a Web browser, manually.
628
629     * Let's say you're developing your Django application and have a "pristine"
630       copy of a database that you'd like to interact with. You can dump your
631       database to a fixture (using the ``dumpdata`` command, explained above),
632       then use ``testserver`` to run your Web application with that data. With
633       this arrangement, you have the flexibility of messing up your data
634       in any way, knowing that whatever data changes you're making are only
635       being made to a test database.
636
637 Note that this server does *not* automatically detect changes to your Python
638 source code (as ``runserver`` does). It does, however, detect changes to
639 templates.
640
641 .. _unit tests: ../testing/
642
643 --addrport [port number or ipaddr:port]
644 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
645
646 Use ``--addrport`` to specify a different port, or IP address and port, from
647 the default of 127.0.0.1:8000. This value follows exactly the same format and
648 serves exactly the same function as the argument to the ``runserver`` subcommand.
649
650 Examples:
651
652 To run the test server on port 7000 with ``fixture1`` and ``fixture2``::
653
654     django-admin.py testserver --addrport 7000 fixture1 fixture2
655     django-admin.py testserver fixture1 fixture2 --addrport 7000
656
657 (The above statements are equivalent. We include both of them to demonstrate
658 that it doesn't matter whether the options come before or after the fixture
659 arguments.)
660
661 To run on 1.2.3.4:7000 with a ``test`` fixture::
662
663     django-admin.py testserver --addrport 1.2.3.4:7000 test
664
665 --verbosity
666 ~~~~~~~~~~~
667
668 Use ``--verbosity`` to specify the amount of notification and debug information
669 that ``django-admin.py`` should print to the console.
670
671         * ``0`` means no input.
672         * ``1`` means normal input (default).
673         * ``2`` means verbose input.
674
675 Example usage::
676
677     django-admin.py testserver --verbosity=2
678
679 validate
680 --------
681
682 Validates all installed models (according to the ``INSTALLED_APPS`` setting)
683 and prints validation errors to standard output.
684
685 Default options
686 ===============
687
688 Although some subcommands may allow their own custom options, every subcommand
689 allows for the following options:
690
691 --pythonpath
692 ------------
693
694 Example usage::
695
696     django-admin.py syncdb --pythonpath='/home/djangoprojects/myproject'
697
698 Adds the given filesystem path to the Python `import search path`_. If this
699 isn't provided, ``django-admin.py`` will use the ``PYTHONPATH`` environment
700 variable.
701
702 Note that this option is unnecessary in ``manage.py``, because it takes care of
703 setting the Python path for you.
704
705 .. _import search path: http://diveintopython.org/getting_to_know_python/everything_is_an_object.html
706
707 --settings
708 ----------
709
710 Example usage::
711
712     django-admin.py syncdb --settings=mysite.settings
713
714 Explicitly specifies the settings module to use. The settings module should be
715 in Python package syntax, e.g. ``mysite.settings``. If this isn't provided,
716 ``django-admin.py`` will use the ``DJANGO_SETTINGS_MODULE`` environment
717 variable.
718
719 Note that this option is unnecessary in ``manage.py``, because it uses
720 ``settings.py`` from the current project by default.
721
722 Extra niceties
723 ==============
724
725 Syntax coloring
726 ---------------
727
728 The ``django-admin.py`` / ``manage.py`` commands that output SQL to standard
729 output will use pretty color-coded output if your terminal supports
730 ANSI-colored output. It won't use the color codes if you're piping the
731 command's output to another program.
732
733 Bash completion
734 ---------------
735
736 If you use the Bash shell, consider installing the Django bash completion
737 script, which lives in ``extras/django_bash_completion`` in the Django
738 distribution. It enables tab-completion of ``django-admin.py`` and
739 ``manage.py`` commands, so you can, for instance...
740
741     * Type ``django-admin.py``.
742     * Press [TAB] to see all available options.
743     * Type ``sql``, then [TAB], to see all available options whose names start
744       with ``sql``.
745
746 Customized actions
747 ==================
748
749 **New in Django development version**
750
751 Applications can register their own actions with ``manage.py``. For example,
752 you might want to add a ``manage.py`` action for a Django app that you're
753 distributing.
754
755 To do this, just add a ``management/commands`` directory to your application.
756 Each Python module in that directory will be auto-discovered and registered as
757 a command that can be executed as an action when you run ``manage.py``::
758
759     blog/
760         __init__.py
761         models.py
762         management/
763             __init__.py
764             commands/
765                 __init__.py
766                 explode.py
767         views.py
768
769 In this example, the ``explode`` command will be made available to any project
770 that includes the ``blog`` application in ``settings.INSTALLED_APPS``.
771
772 The ``explode.py`` module has only one requirement -- it must define a class
773 called ``Command`` that extends ``django.core.management.base.BaseCommand``.
774
775 For more details on how to define your own commands, look at the code for the
776 existing ``django-admin.py`` commands, in ``/django/core/management/commands``.
Note: See TracBrowser for help on using the browser.