Changeset 2760
- Timestamp:
- 04/27/06 23:15:11 (2 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/magic-removal/docs/django-admin.txt
r2744 r2760 1 =========================== 2 The django-admin.py utility3 =========================== 1 ============================= 2 django-admin.py and manage.py 3 ============================= 4 4 5 5 ``django-admin.py`` is Django's command-line utility for administrative tasks. 6 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. 7 16 8 17 The ``django-admin.py`` script should be on your system path if you installed … … 11 20 symlinking to it from some place on your path, such as ``/usr/local/bin``. 12 21 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 of15 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 it20 points to your project's ``settings.py`` file.21 22 22 Generally, when working on a single Django project, it's easier to use 23 23 ``manage.py``. Use ``django-admin.py`` with ``DJANGO_SETTINGS_MODULE``, or the … … 39 39 list of all available actions and options. 40 40 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"``. 41 Most actions take a list of ``appname``s. An ``appname`` is the basename of the 42 package containing your models. For example, if your ``INSTALLED_APPS`` 43 contains the string ``'mysite.blog'``, the ``appname`` is ``blog``. 45 44 46 45 Available actions 47 46 ================= 48 47 49 adminindex [ modelmodule modelmodule ...]50 -------------------------------- --------51 52 Prints the admin-index template snippet for the given model module(s).48 adminindex [appname appname ...] 49 -------------------------------- 50 51 Prints the admin-index template snippet for the given appnames. 53 52 54 53 Use admin-index template snippets if you want to customize the look and feel of … … 76 75 * For SQLite, this runs the ``sqlite3`` command-line client. 77 76 78 This command assumes the programs are on your PATHso that a simple call to77 This command assumes the programs are on your ``PATH`` so that a simple call to 79 78 the program name (``psql``, ``mysql``, ``sqlite3``) will find the program in 80 the right place. 79 the right place. There's no way to specify the location of the program 80 manually. 81 81 82 82 diffsettings … … 90 90 ``ROOT_URLCONF`` is followed by ``"###"`` in the output of ``diffsettings``. 91 91 92 Note that Django's default settings live in ``django/conf/global_settings.py``. 92 Note that Django's default settings live in ``django/conf/global_settings.py``, 93 if you're ever curious to see the full list of defaults. 93 94 94 95 inspectdb … … 96 97 97 98 Introspects 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`` 100 file) to standard output. 99 101 100 102 Use this if you have a legacy database with which you'd like to use Django. … … 125 127 models that refer to other models are ordered properly. 126 128 127 Primary keys are automatically introspected for PostgreSQL and MySQL, and128 Django puts in the ``primary_key=True`` where needed.129 Primary keys are automatically introspected for PostgreSQL and MySQL, in which 130 case Django puts in the ``primary_key=True`` where needed. 129 131 130 132 ``inspectdb`` works with PostgreSQL, MySQL and SQLite. Foreign-key detection 131 133 only works in PostgreSQL and with certain types of MySQL tables. 132 134 133 install [ modelmodule modelmodule ...]134 ----------------------------- --------135 136 Executes the equivalent of ``sqlall`` for the given model module(s).135 install [appname appname ...] 136 ----------------------------- 137 138 Executes the equivalent of ``sqlall`` for the given appnames. 137 139 138 140 runserver [optional port number, or ipaddr:port] … … 145 147 If you run this script as a user with normal privileges (recommended), you 146 148 might not have access to start a port on a low port number. Low port numbers 147 are reserved for superusers(root).149 are reserved for the superuser (root). 148 150 149 151 DO NOT USE THIS SERVER IN A PRODUCTION SETTING. … … 154 156 When you start the server, and each time you change Python code while the 155 157 server is running, the server will validate all of your installed models. (See 156 the "validate" optionbelow.) If the validator finds errors, it will print158 the ``validate`` command below.) If the validator finds errors, it will print 157 159 them to standard output, but it won't stop the server. 158 160 … … 189 191 .. _IPython: http://ipython.scipy.org/ 190 192 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 ...]193 sql [appname appname ...] 194 ------------------------- 195 196 Prints the CREATE TABLE SQL statements for the given appnames. 197 198 sqlall [appname appname ...] 199 ---------------------------- 200 201 Prints the CREATE TABLE and initial-data SQL statements for the given appnames. 202 203 sqlclear [appname appname ...] 202 204 -------------------------------------- 203 205 204 Prints the DROP TABLE SQL statements for the given model module(s).205 206 sqlindexes [ modelmodule modelmodule ...]206 Prints the DROP TABLE SQL statements for the given appnames. 207 208 sqlindexes [appname appname ...] 207 209 ---------------------------------------- 208 210 209 Prints the CREATE INDEX SQL statements for the given model module(s).210 211 sqlinitialdata [ modelmodule modelmodule ...]211 Prints the CREATE INDEX SQL statements for the given appnames. 212 213 sqlinitialdata [appname appname ...] 212 214 -------------------------------------------- 213 215 214 Prints the initial INSERT SQL statements for the given model module(s).215 216 sqlreset [ modelmodule modelmodule ...]216 Prints the initial INSERT SQL statements for the given appnames. 217 218 sqlreset [appname appname ...] 217 219 -------------------------------------- 218 220 219 Prints the DROP TABLE SQL, then the CREATE TABLE SQL, for the given model module(s).220 221 sqlsequencereset [ modelmodule modelmodule ...]221 Prints the DROP TABLE SQL, then the CREATE TABLE SQL, for the given appnames. 222 223 sqlsequencereset [appname appname ...] 222 224 ---------------------------------------------- 223 225 224 226 Prints the SQL statements for resetting PostgreSQL sequences for the given 225 model module(s).227 appnames. 226 228 227 229 See http://simon.incutio.com/archive/2004/04/21/postgres for more information. … … 253 255 Example usage:: 254 256 255 django-admin.py init --settings=myproject.settings257 django-admin.py syncdb --settings=mysite.settings 256 258 257 259 Explicitly 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. 260 in Python package syntax, e.g. ``mysite.settings``. If this isn't provided, 261 ``django-admin.py`` will use the ``DJANGO_SETTINGS_MODULE`` environment 262 variable. 260 263 261 264 Note that this option is unnecessary in ``manage.py``, because it takes care of … … 267 270 Example usage:: 268 271 269 django-admin.py init--pythonpath='/home/djangoprojects/myproject'272 django-admin.py syncdb --pythonpath='/home/djangoprojects/myproject' 270 273 271 274 Adds the given filesystem path to the Python `import search path`_. If this … … 283 286 Displays a help message that includes a terse list of all available actions and 284 287 options. 288 289 Extra niceties 290 ============== 291 292 Syntax coloring 293 --------------- 294 295 The ``django-admin.py`` / ``manage.py`` commands that output SQL to standard 296 output will use pretty color-coded output if your terminal supports 297 ANSI-colored output. It won't use the color codes if you're piping the 298 command's output to another program. 299 300 Bash completion 301 --------------- 302 303 If you use the Bash shell, consider installing the Django bash completion 304 script, which lives in ``extras/django_bash_completion`` in the Django 305 distribution. 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``.
