Django

Code

Changeset 2760

Show
Ignore:
Timestamp:
04/27/06 23:15:11 (2 years ago)
Author:
adrian
Message:

magic-removal: Proofread docs/django-admin.txt and added 'Extra niceties' section

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/magic-removal/docs/django-admin.txt

    r2744 r2760  
    1 =========================== 
    2 The django-admin.py utilit
    3 =========================== 
     1============================= 
     2django-admin.py and manage.p
     3============================= 
    44 
    55``django-admin.py`` is Django's command-line utility for administrative tasks. 
    66This document outlines all it can do. 
     7 
     8In 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 
     10two 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. 
    716 
    817The ``django-admin.py`` script should be on your system path if you installed 
     
    1120symlinking to it from some place on your path, such as ``/usr/local/bin``. 
    1221 
    13 In addition, ``manage.py`` is automatically created in each Django project. 
    14 ``manage.py`` is a thin wrapper around ``django-admin.py`` that takes care of 
    15 two things for you before delegating to ``django-admin.py``: 
    16  
    17     * It puts your project's package on ``sys.path``. 
    18  
    19     * It sets the ``DJANGO_SETTINGS_MODULE`` environment variable so that it 
    20       points to your project's ``settings.py`` file. 
    21  
    2222Generally, when working on a single Django project, it's easier to use 
    2323``manage.py``. Use ``django-admin.py`` with ``DJANGO_SETTINGS_MODULE``, or the 
     
    3939list of all available actions and options. 
    4040 
    41 Most actions take a list of "modelmodule"s. A "modelmodule," in this case, is 
    42 the name of a file containing Django models. For example, if you have a model 
    43 module called ``myproject/apps/polls/pollmodels.py``, the "modelmodule" in this 
    44 case would be ``"pollmodels"``. 
     41Most actions take a list of ``appname``s. An ``appname`` is the basename of the 
     42package containing your models. For example, if your ``INSTALLED_APPS`` 
     43contains the string ``'mysite.blog'``, the ``appname`` is ``blog``. 
    4544 
    4645Available actions 
    4746================= 
    4847 
    49 adminindex [modelmodule modelmodule ...] 
    50 ---------------------------------------- 
    51  
    52 Prints the admin-index template snippet for the given model module(s)
     48adminindex [appname appname ...] 
     49-------------------------------- 
     50 
     51Prints the admin-index template snippet for the given appnames
    5352 
    5453Use admin-index template snippets if you want to customize the look and feel of 
     
    7675    * For SQLite, this runs the ``sqlite3`` command-line client. 
    7776 
    78 This command assumes the programs are on your PATH so that a simple call to 
     77This command assumes the programs are on your ``PATH`` so that a simple call to 
    7978the program name (``psql``, ``mysql``, ``sqlite3``) will find the program in 
    80 the right place. 
     79the right place. There's no way to specify the location of the program 
     80manually. 
    8181 
    8282diffsettings 
     
    9090``ROOT_URLCONF`` is followed by ``"###"`` in the output of ``diffsettings``. 
    9191 
    92 Note that Django's default settings live in ``django/conf/global_settings.py``. 
     92Note that Django's default settings live in ``django/conf/global_settings.py``, 
     93if you're ever curious to see the full list of defaults. 
    9394 
    9495inspectdb 
     
    9697 
    9798Introspects the database tables in the database pointed-to by the 
    98 ``DATABASE_NAME`` setting and outputs a Django model module to standard output. 
     99``DATABASE_NAME`` setting and outputs a Django model module (a ``models.py`` 
     100file) to standard output. 
    99101 
    100102Use this if you have a legacy database with which you'd like to use Django. 
     
    125127models that refer to other models are ordered properly. 
    126128 
    127 Primary keys are automatically introspected for PostgreSQL and MySQL, and 
    128 Django puts in the ``primary_key=True`` where needed. 
     129Primary keys are automatically introspected for PostgreSQL and MySQL, in which 
     130case Django puts in the ``primary_key=True`` where needed. 
    129131 
    130132``inspectdb`` works with PostgreSQL, MySQL and SQLite. Foreign-key detection 
    131133only works in PostgreSQL and with certain types of MySQL tables. 
    132134 
    133 install [modelmodule modelmodule ...] 
    134 ------------------------------------- 
    135  
    136 Executes the equivalent of ``sqlall`` for the given model module(s)
     135install [appname appname ...] 
     136----------------------------- 
     137 
     138Executes the equivalent of ``sqlall`` for the given appnames
    137139 
    138140runserver [optional port number, or ipaddr:port] 
     
    145147If you run this script as a user with normal privileges (recommended), you 
    146148might not have access to start a port on a low port number. Low port numbers 
    147 are reserved for superusers (root). 
     149are reserved for the superuser (root). 
    148150 
    149151DO NOT USE THIS SERVER IN A PRODUCTION SETTING. 
     
    154156When you start the server, and each time you change Python code while the 
    155157server is running, the server will validate all of your installed models. (See 
    156 the "validate" option below.) If the validator finds errors, it will print 
     158the ``validate`` command below.) If the validator finds errors, it will print 
    157159them to standard output, but it won't stop the server. 
    158160 
     
    189191.. _IPython: http://ipython.scipy.org/ 
    190192 
    191 sql [modelmodule modelmodule ...] 
    192 --------------------------------- 
    193  
    194 Prints the CREATE TABLE SQL statements for the given model module(s)
    195  
    196 sqlall [modelmodule modelmodule ...] 
    197 ------------------------------------ 
    198  
    199 Prints the CREATE TABLE and initial-data SQL statements for the given model module(s)
    200  
    201 sqlclear [modelmodule modelmodule ...] 
     193sql [appname appname ...] 
     194------------------------- 
     195 
     196Prints the CREATE TABLE SQL statements for the given appnames
     197 
     198sqlall [appname appname ...] 
     199---------------------------- 
     200 
     201Prints the CREATE TABLE and initial-data SQL statements for the given appnames
     202 
     203sqlclear [appname appname ...] 
    202204-------------------------------------- 
    203205 
    204 Prints the DROP TABLE SQL statements for the given model module(s)
    205  
    206 sqlindexes [modelmodule modelmodule ...] 
     206Prints the DROP TABLE SQL statements for the given appnames
     207 
     208sqlindexes [appname appname ...] 
    207209---------------------------------------- 
    208210 
    209 Prints the CREATE INDEX SQL statements for the given model module(s)
    210  
    211 sqlinitialdata [modelmodule modelmodule ...] 
     211Prints the CREATE INDEX SQL statements for the given appnames
     212 
     213sqlinitialdata [appname appname ...] 
    212214-------------------------------------------- 
    213215 
    214 Prints the initial INSERT SQL statements for the given model module(s)
    215  
    216 sqlreset [modelmodule modelmodule ...] 
     216Prints the initial INSERT SQL statements for the given appnames
     217 
     218sqlreset [appname appname ...] 
    217219-------------------------------------- 
    218220 
    219 Prints the DROP TABLE SQL, then the CREATE TABLE SQL, for the given model module(s)
    220  
    221 sqlsequencereset [modelmodule modelmodule ...] 
     221Prints the DROP TABLE SQL, then the CREATE TABLE SQL, for the given appnames
     222 
     223sqlsequencereset [appname appname ...] 
    222224---------------------------------------------- 
    223225 
    224226Prints the SQL statements for resetting PostgreSQL sequences for the given 
    225 model module(s)
     227appnames
    226228 
    227229See http://simon.incutio.com/archive/2004/04/21/postgres for more information. 
     
    253255Example usage:: 
    254256 
    255     django-admin.py init --settings=myproject.settings 
     257    django-admin.py syncdb --settings=mysite.settings 
    256258 
    257259Explicitly specifies the settings module to use. The settings module should be 
    258 in Python path syntax, e.g. "myproject.settings". If this isn't provided, 
    259 ``django-admin.py`` will use the DJANGO_SETTINGS_MODULE environment variable. 
     260in Python package syntax, e.g. ``mysite.settings``. If this isn't provided, 
     261``django-admin.py`` will use the ``DJANGO_SETTINGS_MODULE`` environment 
     262variable. 
    260263 
    261264Note that this option is unnecessary in ``manage.py``, because it takes care of 
     
    267270Example usage:: 
    268271 
    269     django-admin.py init --pythonpath='/home/djangoprojects/myproject' 
     272    django-admin.py syncdb --pythonpath='/home/djangoprojects/myproject' 
    270273 
    271274Adds the given filesystem path to the Python `import search path`_. If this 
     
    283286Displays a help message that includes a terse list of all available actions and 
    284287options. 
     288 
     289Extra niceties 
     290============== 
     291 
     292Syntax coloring 
     293--------------- 
     294 
     295The ``django-admin.py`` / ``manage.py`` commands that output SQL to standard 
     296output will use pretty color-coded output if your terminal supports 
     297ANSI-colored output. It won't use the color codes if you're piping the 
     298command's output to another program. 
     299 
     300Bash completion 
     301--------------- 
     302 
     303If you use the Bash shell, consider installing the Django bash completion 
     304script, which lives in ``extras/django_bash_completion`` in the Django 
     305distribution. It enables tab-completion of ``django-admin.py`` and 
     306``manage.py`` commands, so you can, for instance... 
     307 
     308    * Type ``django-admin.py``. 
     309    * Press [TAB] to see all available options. 
     310    * Type ``sql``, then [TAB], to see all available options whose names start 
     311      with ``sql``.