~gary-wilson/django/cache-reorg

« back to all changes in this revision

Viewing changes to docs/django-admin.txt

  • Committer: Gary Wilson
  • Date: 2007-10-28 22:17:58 UTC
  • mfrom: (3786.1.415)
  • Revision ID: gary.wilson@gmail.com-20071028221758-jq4dxnf6idol3ioo
MergedĀ upstreamĀ changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
Usage
36
36
=====
37
37
 
38
 
``django-admin.py action [options]``
39
 
 
40
 
``manage.py action [options]``
41
 
 
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
44
 
document.
45
 
 
46
 
Run ``django-admin.py --help`` to display a help message that includes a terse
47
 
list of all available actions and options.
48
 
 
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``.
52
 
 
53
 
Available actions
54
 
=================
55
 
 
56
 
adminindex [appname appname ...]
 
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 ...>
57
79
--------------------------------
58
80
 
59
 
Prints the admin-index template snippet for the given appnames.
 
81
Prints the admin-index template snippet for the given app name(s).
60
82
 
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.
63
85
 
64
86
.. _Tutorial 2: ../tutorial02/
65
87
 
66
 
createcachetable [tablename]
 
88
createcachetable <tablename>
67
89
----------------------------
68
90
 
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.
71
93
 
72
94
.. _cache documentation: ../cache/
73
95
 
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.
102
124
 
103
 
dumpdata [appname appname ...]
 
125
dumpdata <appname appname ...>
104
126
------------------------------
105
127
 
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
107
129
application(s).
108
130
 
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.
114
 
 
115
131
If no application name is provided, all installed applications will be dumped.
116
132
 
117
133
The output of ``dumpdata`` can be used as input for ``loaddata``.
118
134
 
 
135
--format
 
136
~~~~~~~~
 
137
 
 
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`_.
 
141
 
 
142
Example usage::
 
143
 
 
144
    django-admin.py dumpdata --format=xml
 
145
 
 
146
.. _Serialization formats: ../serialization/#serialization-formats
 
147
 
 
148
--indent
 
149
~~~~~~~~
 
150
 
 
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.
 
154
 
 
155
Example usage::
 
156
 
 
157
    django-admin.py dumpdata --indent=4
 
158
 
119
159
flush
120
160
-----
121
161
 
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``.
133
173
 
 
174
--noinput
 
175
~~~~~~~~~
 
176
 
 
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.
 
180
 
 
181
--verbosity
 
182
~~~~~~~~~~~
 
183
 
 
184
Use ``--verbosity`` to specify the amount of notification and debug information
 
185
that ``django-admin.py`` should print to the console.
 
186
 
 
187
        * ``0`` means no input.
 
188
        * ``1`` means normal input (default).
 
189
        * ``2`` means verbose input.
 
190
 
 
191
Example usage::
 
192
 
 
193
    django-admin.py flush --verbosity=2
 
194
 
134
195
inspectdb
135
196
---------
136
197
 
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.
174
235
 
175
 
loaddata [fixture fixture ...]
 
236
loaddata <fixture fixture ...>
176
237
------------------------------
177
238
 
178
239
Searches for and loads the contents of the named fixture into the database.
179
240
 
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.
184
244
 
185
245
Django will search in three locations for fixtures:
186
246
 
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.
242
302
 
243
 
reset [appname appname ...]
 
303
--verbosity
 
304
~~~~~~~~~~~
 
305
 
 
306
Use ``--verbosity`` to specify the amount of notification and debug information
 
307
that ``django-admin.py`` should print to the console.
 
308
 
 
309
        * ``0`` means no input.
 
310
        * ``1`` means normal input (default).
 
311
        * ``2`` means verbose input.
 
312
 
 
313
Example usage::
 
314
 
 
315
    django-admin.py loaddata --verbosity=2
 
316
 
 
317
reset <appname appname ...>
244
318
---------------------------
245
319
 
246
 
Executes the equivalent of ``sqlreset`` for the given appnames.
 
320
Executes the equivalent of ``sqlreset`` for the given app name(s).
 
321
 
 
322
--noinput
 
323
~~~~~~~~~
 
324
 
 
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.
247
328
 
248
329
runfcgi [options]
249
330
-----------------
250
331
 
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
254
335
`flup`_.
255
336
 
289
370
machines on the network, use its own IP address (e.g. ``192.168.2.1``) or
290
371
``0.0.0.0``.
291
372
 
292
 
Examples:
293
 
~~~~~~~~~
 
373
--adminmedia
 
374
~~~~~~~~~~~~
 
375
 
 
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.
 
380
 
 
381
Example usage::
 
382
 
 
383
    django-admin.py runserver --adminmedia=/tmp/new-admin-style/
 
384
 
 
385
--noreload
 
386
~~~~~~~~~~
 
387
 
 
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
 
391
memory.
 
392
 
 
393
Examples of using different ports and addresses
 
394
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
395
 
 
396
Port 8000 on IP address 127.0.0.1::
 
397
 
 
398
        django-admin.py runserver
 
399
 
 
400
Port 8000 on IP address 1.2.3.4::
 
401
 
 
402
        django-admin.py runserver 1.2.3.4:8000
294
403
 
295
404
Port 7000 on IP address 127.0.0.1::
296
405
 
331
440
 
332
441
.. _IPython: http://ipython.scipy.org/
333
442
 
334
 
sql [appname appname ...]
 
443
sql <appname appname ...>
335
444
-------------------------
336
445
 
337
 
Prints the CREATE TABLE SQL statements for the given appnames.
 
446
Prints the CREATE TABLE SQL statements for the given app name(s).
338
447
 
339
 
sqlall [appname appname ...]
 
448
sqlall <appname appname ...>
340
449
----------------------------
341
450
 
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).
343
452
 
344
453
Refer to the description of ``sqlcustom`` for an explanation of how to
345
454
specify initial data.
346
455
 
347
 
sqlclear [appname appname ...]
 
456
sqlclear <appname appname ...>
348
457
------------------------------
349
458
 
350
 
Prints the DROP TABLE SQL statements for the given appnames.
 
459
Prints the DROP TABLE SQL statements for the given app name(s).
351
460
 
352
 
sqlcustom [appname appname ...]
 
461
sqlcustom <appname appname ...>
353
462
-------------------------------
354
463
 
355
 
Prints the custom SQL statements for the given appnames.
 
464
Prints the custom SQL statements for the given app name(s).
356
465
 
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
373
482
 
374
483
Prints the SQL statements that would be executed for the `flush`_ command.
375
484
 
376
 
sqlindexes [appname appname ...]
 
485
sqlindexes <appname appname ...>
377
486
--------------------------------
378
487
 
379
 
Prints the CREATE INDEX SQL statements for the given appnames.
 
488
Prints the CREATE INDEX SQL statements for the given app name(s).
380
489
 
381
 
sqlreset [appname appname ...]
 
490
sqlreset <appname appname ...>
382
491
------------------------------
383
492
 
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).
385
494
 
386
 
sqlsequencereset [appname appname ...]
 
495
sqlsequencereset <appname appname ...>
387
496
--------------------------------------
388
497
 
389
 
Prints the SQL statements for resetting sequences for the given
390
 
appnames.
 
498
Prints the SQL statements for resetting sequences for the given app name(s).
391
499
 
392
500
See http://simon.incutio.com/archive/2004/04/21/postgres for more information.
393
501
 
394
 
startapp [appname]
 
502
startapp <appname>
395
503
------------------
396
504
 
397
505
Creates a Django app directory structure for the given app name in the current
398
506
directory.
399
507
 
400
 
startproject [projectname]
 
508
startproject <projectname>
401
509
--------------------------
402
510
 
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
436
544
data files.
437
545
 
 
546
--verbosity
 
547
~~~~~~~~~~~
 
548
 
 
549
Use ``--verbosity`` to specify the amount of notification and debug information
 
550
that ``django-admin.py`` should print to the console.
 
551
 
 
552
        * ``0`` means no input.
 
553
        * ``1`` means normal input (default).
 
554
        * ``2`` means verbose input.
 
555
 
 
556
Example usage::
 
557
 
 
558
    django-admin.py syncdb --verbosity=2
 
559
 
 
560
--noinput
 
561
~~~~~~~~~
 
562
 
 
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.
 
566
 
438
567
test
439
568
----
440
569
 
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.
442
572
 
443
573
.. _testing Django applications: ../testing/
444
574
 
445
 
testserver [fixture fixture ...]
 
575
--noinput
 
576
~~~~~~~~~
 
577
 
 
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.
 
581
 
 
582
--verbosity
 
583
~~~~~~~~~~~
 
584
 
 
585
Use ``--verbosity`` to specify the amount of notification and debug information
 
586
that ``django-admin.py`` should print to the console.
 
587
 
 
588
        * ``0`` means no input.
 
589
        * ``1`` means normal input (default).
 
590
        * ``2`` means verbose input.
 
591
 
 
592
Example usage::
 
593
 
 
594
    django-admin.py test --verbosity=2
 
595
 
 
596
testserver <fixture fixture ...>
446
597
--------------------------------
447
598
 
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.
478
629
 
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.
481
 
 
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
 
632
templates.
484
633
 
485
634
.. _unit tests: ../testing/
486
635
 
 
636
--addrport [port number or ipaddr:port]
 
637
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
638
 
 
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.
 
642
 
 
643
Examples:
 
644
 
 
645
To run the test server on port 7000 with ``fixture1`` and ``fixture2``::
 
646
 
 
647
    django-admin.py testserver --addrport 7000 fixture1 fixture2
 
648
    django-admin.py testserver fixture1 fixture2 --addrport 7000
 
649
 
 
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
 
652
arguments.)
 
653
 
 
654
To run on 1.2.3.4:7000 with a `test` fixture::
 
655
 
 
656
    django-admin.py testserver --addrport 1.2.3.4:7000 test
 
657
 
 
658
--verbosity
 
659
~~~~~~~~~~~
 
660
 
 
661
Use ``--verbosity`` to specify the amount of notification and debug information
 
662
that ``django-admin.py`` should print to the console.
 
663
 
 
664
        * ``0`` means no input.
 
665
        * ``1`` means normal input (default).
 
666
        * ``2`` means verbose input.
 
667
 
 
668
Example usage::
 
669
 
 
670
    django-admin.py testserver --verbosity=2
 
671
 
487
672
validate
488
673
--------
489
674
 
490
675
Validates all installed models (according to the ``INSTALLED_APPS`` setting)
491
676
and prints validation errors to standard output.
492
677
 
493
 
Available options
494
 
=================
 
678
Default options
 
679
===============
 
680
 
 
681
Although some subcommands may allow their own custom options, every subcommand
 
682
allows for the following options:
 
683
 
 
684
--pythonpath
 
685
------------
 
686
 
 
687
Example usage::
 
688
 
 
689
    django-admin.py syncdb --pythonpath='/home/djangoprojects/myproject'
 
690
 
 
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
 
693
variable.
 
694
 
 
695
Note that this option is unnecessary in ``manage.py``, because it takes care of
 
696
setting the Python path for you.
 
697
 
 
698
.. _import search path: http://diveintopython.org/getting_to_know_python/everything_is_an_object.html
495
699
 
496
700
--settings
497
701
----------
508
712
Note that this option is unnecessary in ``manage.py``, because it takes care of
509
713
setting ``DJANGO_SETTINGS_MODULE`` for you.
510
714
 
511
 
--pythonpath
512
 
------------
513
 
 
514
 
Example usage::
515
 
 
516
 
    django-admin.py syncdb --pythonpath='/home/djangoprojects/myproject'
517
 
 
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
520
 
variable.
521
 
 
522
 
Note that this option is unnecessary in ``manage.py``, because it takes care of
523
 
setting the Python path for you.
524
 
 
525
 
.. _import search path: http://diveintopython.org/getting_to_know_python/everything_is_an_object.html
526
 
 
527
 
--format
528
 
--------
529
 
 
530
 
Example usage::
531
 
 
532
 
    django-admin.py dumpdata --format=xml
533
 
 
534
 
Specifies the output format that will be used. The name provided must be the name
535
 
of a registered serializer.
536
 
 
537
 
--help
538
 
------
539
 
 
540
 
Displays a help message that includes a terse list of all available actions and
541
 
options.
542
 
 
543
 
--indent
544
 
--------
545
 
 
546
 
Example usage::
547
 
 
548
 
    django-admin.py dumpdata --indent=4
549
 
 
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.
553
 
 
554
 
--noinput
555
 
---------
556
 
 
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
559
 
script.
560
 
 
561
 
--noreload
562
 
----------
563
 
 
564
 
Disable the use of the auto-reloader when running the development server.
565
 
 
566
 
--version
567
 
---------
568
 
 
569
 
Displays the current Django version.
570
 
 
571
 
Example output::
572
 
 
573
 
    0.9.1
574
 
    0.9.1 (SVN)
575
 
 
576
 
--verbosity
577
 
-----------
578
 
 
579
 
Example usage::
580
 
 
581
 
    django-admin.py syncdb --verbosity=2
582
 
 
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.
586
 
 
587
 
--adminmedia
588
 
------------
589
 
 
590
 
Example usage::
591
 
 
592
 
    django-admin.py --adminmedia=/tmp/new-admin-style/
593
 
 
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.
598
 
 
599
715
Extra niceties
600
716
==============
601
717
 
619
735
    * Press [TAB] to see all available options.
620
736
    * Type ``sql``, then [TAB], to see all available options whose names start
621
737
      with ``sql``.
 
738
 
 
739
Customized actions
 
740
==================
 
741
 
 
742
**New in Django development version**
 
743
 
 
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
 
746
distributing.
 
747
 
 
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``::
 
751
 
 
752
    blog/
 
753
        __init__.py
 
754
        models.py
 
755
        management/
 
756
            __init__.py
 
757
            commands/
 
758
                __init__.py
 
759
                explode.py
 
760
        views.py
 
761
        
 
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``.
 
764
 
 
765
The ``explode.py`` module has only one requirement -- it must define a class
 
766
called ``Command`` that extends ``django.core.management.base.BaseCommand``.
 
767
 
 
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``.