Django

Code

Show
Ignore:
Timestamp:
06/17/07 17:18:54 (2 years ago)
Author:
clong
Message:

per-object-permissions: Merged to trunk [5486] NOTE: Not fully tested, will be working on this over the next few weeks.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/per-object-permissions/docs/django-admin.txt

    r3940 r5488  
    1818Django via its ``setup.py`` utility. If it's not on your path, you can find it in 
    1919``site-packages/django/bin`` within your Python installation. Consider 
    20 symlinking to it from some place on your path, such as ``/usr/local/bin``. 
     20symlinking it from some place on your path, such as ``/usr/local/bin``. 
     21 
     22For Windows users, who do not have symlinking functionality available, you 
     23can copy ``django-admin.py`` to a location on your existing path or edit the 
     24``PATH`` settings (under ``Settings - Control Panel - System - Advanced - Environment...``) 
     25to point to its installed location. 
    2126 
    2227Generally, when working on a single Django project, it's easier to use 
     
    2530Django settings files. 
    2631 
     32The command-line examples throughout this document use ``django-admin.py`` to 
     33be consistent, but any example can use ``manage.py`` just as well. 
     34 
    2735Usage 
    2836===== 
     
    5462your admin's index page. See `Tutorial 2`_ for more information. 
    5563 
    56 .. _Tutorial 2: http://www.djangoproject.com/documentation/tutorial2/ 
     64.. _Tutorial 2: ../tutorial02/ 
    5765 
    5866createcachetable [tablename] 
     
    6270backend.  See the `cache documentation`_ for more information. 
    6371 
    64 .. _cache documentation: http://www.djangoproject.com/documentation/cache/ 
     72.. _cache documentation: ../cache/ 
    6573 
    6674dbshell 
     
    92100Note that Django's default settings live in ``django/conf/global_settings.py``, 
    93101if you're ever curious to see the full list of defaults. 
     102 
     103dumpdata [appname appname ...] 
     104------------------------------ 
     105 
     106Output to standard output all data in the database associated with the named 
     107application(s). 
     108 
     109By default, the database will be dumped in JSON format. If you want the output 
     110to be in another format, use the ``--format`` option (e.g., ``format=xml``). 
     111You may specify any Django serialization backend (including any user specified 
     112serialization backends named in the ``SERIALIZATION_MODULES`` setting). The 
     113``--indent`` option can be used to pretty-print the output. 
     114 
     115If no application name is provided, all installed applications will be dumped. 
     116 
     117The output of ``dumpdata`` can be used as input for ``loaddata``. 
     118 
     119flush 
     120----- 
     121 
     122Return the database to the state it was in immediately after syncdb was 
     123executed. This means that all data will be removed from the database, any 
     124post-synchronization handlers will be re-executed, and the ``initial_data`` 
     125fixture will be re-installed. 
    94126 
    95127inspectdb 
     
    134166only works in PostgreSQL and with certain types of MySQL tables. 
    135167 
    136 install [appname appname ...] 
    137 ----------------------------- 
    138  
    139 Executes the equivalent of ``sqlall`` for the given appnames. 
     168loaddata [fixture fixture ...] 
     169------------------------------ 
     170 
     171Searches for and loads the contents of the named fixture into the database. 
     172 
     173A *Fixture* is a collection of files that contain the serialized contents of 
     174the database. Each fixture has a unique name; however, the files that 
     175comprise the fixture can be distributed over multiple directories, in 
     176multiple applications. 
     177 
     178Django will search in three locations for fixtures: 
     179 
     180   1. In the ``fixtures`` directory of every installed application 
     181   2. In any directory named in the ``FIXTURE_DIRS`` setting 
     182   3. In the literal path named by the fixture 
     183 
     184Django will load any and all fixtures it finds in these locations that match 
     185the provided fixture names. 
     186 
     187If the named fixture has a file extension, only fixtures of that type 
     188will be loaded. For example:: 
     189 
     190    django-admin.py loaddata mydata.json 
     191 
     192would only load JSON fixtures called ``mydata``. The fixture extension 
     193must correspond to the registered name of a serializer (e.g., ``json`` or 
     194``xml``). 
     195 
     196If you omit the extension, Django will search all available fixture types 
     197for a matching fixture. For example:: 
     198 
     199    django-admin.py loaddata mydata 
     200 
     201would look for any fixture of any fixture type called ``mydata``. If a fixture 
     202directory contained ``mydata.json``, that fixture would be loaded 
     203as a JSON fixture. However, if two fixtures with the same name but different 
     204fixture type are discovered (for example, if ``mydata.json`` and 
     205``mydata.xml`` were found in the same fixture directory), fixture 
     206installation will be aborted, and any data installed in the call to 
     207``loaddata`` will be removed from the database. 
     208 
     209The fixtures that are named can include directory components. These 
     210directories will be included in the search path. For example:: 
     211 
     212    django-admin.py loaddata foo/bar/mydata.json 
     213 
     214would search ``<appname>/fixtures/foo/bar/mydata.json`` for each installed 
     215application,  ``<dirname>/foo/bar/mydata.json`` for each directory in 
     216``FIXTURE_DIRS``, and the literal path ``foo/bar/mydata.json``. 
     217 
     218Note that the order in which fixture files are processed is undefined. However, 
     219all fixture data is installed as a single transaction, so data in 
     220one fixture can reference data in another fixture. If the database backend 
     221supports row-level constraints, these constraints will be checked at the 
     222end of the transaction. 
     223 
     224The ``dumpdata`` command can be used to generate input for ``loaddata``. 
     225 
     226.. admonition:: MySQL and Fixtures 
     227 
     228    Unfortunately, MySQL isn't capable of completely supporting all the 
     229    features of Django fixtures. If you use MyISAM tables, MySQL doesn't 
     230    support transactions or constraints, so you won't get a rollback if 
     231    multiple transaction files are found, or validation of fixture data. 
     232    If you use InnoDB tables, you won't be able to have any forward 
     233    references in your data files - MySQL doesn't provide a mechanism to 
     234    defer checking of row constraints until a transaction is committed. 
     235 
     236reset [appname appname ...] 
     237--------------------------- 
     238Executes the equivalent of ``sqlreset`` for the given appnames. 
     239 
     240runfcgi [options] 
     241----------------- 
     242Starts a set of FastCGI processes suitable for use with any web server 
     243which supports the FastCGI protocol. See the `FastCGI deployment 
     244documentation`_ for details. Requires the Python FastCGI module from 
     245`flup`_. 
     246 
     247.. _FastCGI deployment documentation: ../fastcgi/ 
     248.. _flup: http://www.saddi.com/software/flup/ 
    140249 
    141250runserver [optional port number, or ipaddr:port] 
     
    187296 
    188297By default, the development server doesn't serve any static files for your site 
    189 (such as CSS files, images, things under ``MEDIA_ROOT_URL`` and so forth). If 
     298(such as CSS files, images, things under ``MEDIA_URL`` and so forth). If 
    190299you want to configure Django to serve static media, read the `serving static files`_ 
    191300documentation. 
    192301 
    193 .. _serving static files: http://www.djangoproject.com/documentation/static_files/ 
     302.. _serving static files: ../static_files/ 
    194303 
    195304Turning off auto-reload 
     
    224333Prints the CREATE TABLE and initial-data SQL statements for the given appnames. 
    225334 
    226 Refer to the description of ``sqlinitialdata`` for an explanation of how to 
     335Refer to the description of ``sqlcustom`` for an explanation of how to 
    227336specify initial data. 
    228337 
     
    232341Prints the DROP TABLE SQL statements for the given appnames. 
    233342 
    234 sqlindexes [appname appname ...] 
    235 ---------------------------------------- 
    236  
    237 Prints the CREATE INDEX SQL statements for the given appnames. 
    238  
    239 sqlinitialdata [appname appname ...] 
    240 -------------------------------------------- 
    241  
    242 Prints the initial INSERT SQL statements for the given appnames. 
     343sqlcustom [appname appname ...] 
     344------------------------------- 
     345 
     346Prints the custom SQL statements for the given appnames. 
    243347 
    244348For each model in each specified app, this command looks for the file 
    245349``<appname>/sql/<modelname>.sql``, where ``<appname>`` is the given appname and 
    246350``<modelname>`` is the model's name in lowercase. For example, if you have an 
    247 app ``news`` that includes a ``Story`` model, ``sqlinitialdata`` will attempt 
     351app ``news`` that includes a ``Story`` model, ``sqlcustom`` will attempt 
    248352to read a file ``news/sql/story.sql`` and append it to the output of this 
    249353command. 
     
    251355Each of the SQL files, if given, is expected to contain valid SQL. The SQL 
    252356files are piped directly into the database after all of the models' 
    253 table-creation statements have been executed. Use this SQL hook to populate 
    254 tables with any necessary initial records, SQL functions or test data. 
     357table-creation statements have been executed. Use this SQL hook to make any 
     358table modifications, or insert any SQL functions into the database. 
     359 
     360Note that the order in which the SQL files are processed is undefined. 
     361 
     362sqlindexes [appname appname ...] 
     363---------------------------------------- 
     364 
     365Prints the CREATE INDEX SQL statements for the given appnames. 
    255366 
    256367sqlreset [appname appname ...] 
     
    262373---------------------------------------------- 
    263374 
    264 Prints the SQL statements for resetting PostgreSQL sequences for the given 
     375Prints the SQL statements for resetting sequences for the given 
    265376appnames. 
    266377 
     
    293404give you the option of creating a superuser immediately. 
    294405 
     406``syncdb`` will also search for and install any fixture named ``initial_data`` 
     407with an appropriate extension (e.g. ``json`` or ``xml``). See the 
     408documentation for ``loaddata`` for details on the specification of fixture 
     409data files. 
     410 
    295411test 
    296412---- 
    297  
    298 **New in Django development version** 
    299413 
    300414Discover and run tests for all installed models.  See `Testing Django applications`_ for more information. 
     
    342456.. _import search path: http://diveintopython.org/getting_to_know_python/everything_is_an_object.html 
    343457 
     458--format 
     459-------- 
     460 
     461Example usage:: 
     462 
     463    django-admin.py dumpdata --format=xml 
     464 
     465Specifies the output format that will be used. The name provided must be the name 
     466of a registered serializer. 
     467 
    344468--help 
    345469------ 
     
    348472options. 
    349473 
     474--indent 
     475-------- 
     476 
     477Example usage:: 
     478 
     479    django-admin.py dumpdata --indent=4 
     480 
     481Specifies the number of spaces that will be used for indentation when 
     482pretty-printing output. By default, output will *not* be pretty-printed. 
     483Pretty-printing will only be enabled if the indent option is provided. 
     484 
    350485--noinput 
    351486--------- 
    352  
    353 **New in Django development version** 
    354487 
    355488Inform django-admin that the user should NOT be prompted for any input. Useful 
     
    375508----------- 
    376509 
    377 **New in Django development version** 
    378  
    379510Example usage:: 
    380511 
    381512    django-admin.py syncdb --verbosity=2 
    382513 
    383 Verbosity determines the amount of notification and debug information that  
     514Verbosity determines the amount of notification and debug information that 
    384515will be printed to the console. '0' is no output, '1' is normal output, 
    385516and `2` is verbose output. 
     
    388519------------ 
    389520 
    390 **New in Django development version** 
    391  
    392521Example usage:: 
    393     django-admin.py manage.py --adminmedia=/tmp/new-admin-style/ 
     522 
     523    django-admin.py --adminmedia=/tmp/new-admin-style/ 
    394524 
    395525Tells Django where to find the various CSS and JavaScript files for the admin