django-admin.txt 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475
  1. =============================
  2. django-admin.py and manage.py
  3. =============================
  4. ``django-admin.py`` is Django's command-line utility for administrative tasks.
  5. This document outlines all it can do.
  6. In addition, ``manage.py`` is automatically created in each Django project.
  7. ``manage.py`` is a thin wrapper around ``django-admin.py`` that takes care of
  8. two things for you before delegating to ``django-admin.py``:
  9. * It puts your project's package on ``sys.path``.
  10. * It sets the :envvar:`DJANGO_SETTINGS_MODULE` environment variable so that
  11. it points to your project's ``settings.py`` file.
  12. The ``django-admin.py`` script should be on your system path if you installed
  13. Django via its ``setup.py`` utility. If it's not on your path, you can find it
  14. in ``site-packages/django/bin`` within your Python installation. Consider
  15. symlinking it from some place on your path, such as ``/usr/local/bin``.
  16. For Windows users, who do not have symlinking functionality available, you can
  17. copy ``django-admin.py`` to a location on your existing path or edit the
  18. ``PATH`` settings (under ``Settings - Control Panel - System - Advanced -
  19. Environment...``) to point to its installed location.
  20. Generally, when working on a single Django project, it's easier to use
  21. ``manage.py``. Use ``django-admin.py`` with ``DJANGO_SETTINGS_MODULE``, or the
  22. ``--settings`` command line option, if you need to switch between multiple
  23. Django settings files.
  24. The command-line examples throughout this document use ``django-admin.py`` to
  25. be consistent, but any example can use ``manage.py`` just as well.
  26. Usage
  27. =====
  28. .. code-block:: bash
  29. django-admin.py <command> [options]
  30. manage.py <command> [options]
  31. ``command`` should be one of the commands listed in this document.
  32. ``options``, which is optional, should be zero or more of the options available
  33. for the given command.
  34. Getting runtime help
  35. --------------------
  36. .. django-admin:: help
  37. Run ``django-admin.py help`` to display usage information and a list of the
  38. commands provided by each application.
  39. Run ``django-admin.py help --commands`` to display a list of all available
  40. commands.
  41. Run ``django-admin.py help <command>`` to display a description of the given
  42. command and a list of its available options.
  43. App names
  44. ---------
  45. Many commands take a list of "app names." An "app name" is the basename of
  46. the package containing your models. For example, if your :setting:`INSTALLED_APPS`
  47. contains the string ``'mysite.blog'``, the app name is ``blog``.
  48. Determining the version
  49. -----------------------
  50. .. django-admin:: version
  51. Run ``django-admin.py version`` to display the current Django version.
  52. The output follows the schema described in :pep:`386`::
  53. 1.4.dev17026
  54. 1.4a1
  55. 1.4
  56. Displaying debug output
  57. -----------------------
  58. Use :djadminopt:`--verbosity` to specify the amount of notification and debug information
  59. that ``django-admin.py`` should print to the console. For more details, see the
  60. documentation for the :djadminopt:`--verbosity` option.
  61. Available commands
  62. ==================
  63. cleanup
  64. -------
  65. .. django-admin:: cleanup
  66. Can be run as a cronjob or directly to clean out old data from the database
  67. (only expired sessions at the moment).
  68. compilemessages
  69. ---------------
  70. .. django-admin:: compilemessages
  71. Compiles .po files created with ``makemessages`` to .mo files for use with
  72. the builtin gettext support. See :doc:`/topics/i18n/index`.
  73. Use the :djadminopt:`--locale` option to specify the locale to process.
  74. If not provided, all locales are processed.
  75. Example usage::
  76. django-admin.py compilemessages --locale=br_PT
  77. createcachetable
  78. ----------------
  79. .. django-admin:: createcachetable
  80. Creates a cache table named ``tablename`` for use with the database cache
  81. backend. See :doc:`/topics/cache` for more information.
  82. .. versionadded:: 1.2
  83. The :djadminopt:`--database` option can be used to specify the database
  84. onto which the cachetable will be installed.
  85. dbshell
  86. -------
  87. .. django-admin:: dbshell
  88. Runs the command-line client for the database engine specified in your
  89. ``ENGINE`` setting, with the connection parameters specified in your
  90. :setting:`USER`, :setting:`PASSWORD`, etc., settings.
  91. * For PostgreSQL, this runs the ``psql`` command-line client.
  92. * For MySQL, this runs the ``mysql`` command-line client.
  93. * For SQLite, this runs the ``sqlite3`` command-line client.
  94. This command assumes the programs are on your ``PATH`` so that a simple call to
  95. the program name (``psql``, ``mysql``, ``sqlite3``) will find the program in
  96. the right place. There's no way to specify the location of the program
  97. manually.
  98. .. versionadded:: 1.2
  99. The :djadminopt:`--database` option can be used to specify the database
  100. onto which to open a shell.
  101. diffsettings
  102. ------------
  103. .. django-admin:: diffsettings
  104. Displays differences between the current settings file and Django's default
  105. settings.
  106. Settings that don't appear in the defaults are followed by ``"###"``. For
  107. example, the default settings don't define :setting:`ROOT_URLCONF`, so
  108. :setting:`ROOT_URLCONF` is followed by ``"###"`` in the output of
  109. ``diffsettings``.
  110. Note that Django's default settings live in ``django/conf/global_settings.py``,
  111. if you're ever curious to see the full list of defaults.
  112. dumpdata <appname appname appname.Model ...>
  113. --------------------------------------------
  114. .. django-admin:: dumpdata
  115. Outputs to standard output all data in the database associated with the named
  116. application(s).
  117. If no application name is provided, all installed applications will be dumped.
  118. The output of ``dumpdata`` can be used as input for ``loaddata``.
  119. Note that ``dumpdata`` uses the default manager on the model for selecting the
  120. records to dump. If you're using a :ref:`custom manager <custom-managers>` as
  121. the default manager and it filters some of the available records, not all of the
  122. objects will be dumped.
  123. .. versionadded:: 1.3
  124. The :djadminopt:`--all` option may be provided to specify that
  125. ``dumpdata`` should use Django's base manager, dumping records which
  126. might otherwise be filtered or modified by a custom manager.
  127. .. django-admin-option:: --format <fmt>
  128. By default, ``dumpdata`` will format its output in JSON, but you can use the
  129. ``--format`` option to specify another format. Currently supported formats
  130. are listed in :ref:`serialization-formats`.
  131. .. django-admin-option:: --indent <num>
  132. By default, ``dumpdata`` will output all data on a single line. This isn't
  133. easy for humans to read, so you can use the ``--indent`` option to
  134. pretty-print the output with a number of indentation spaces.
  135. The :djadminopt:`--exclude` option may be provided to prevent specific
  136. applications from being dumped.
  137. .. versionadded:: 1.3
  138. The :djadminopt:`--exclude` option may also be provided to prevent specific
  139. models (specified as in the form of ``appname.ModelName``) from being dumped.
  140. In addition to specifying application names, you can provide a list of
  141. individual models, in the form of ``appname.Model``. If you specify a model
  142. name to ``dumpdata``, the dumped output will be restricted to that model,
  143. rather than the entire application. You can also mix application names and
  144. model names.
  145. .. versionadded:: 1.2
  146. The :djadminopt:`--database` option can be used to specify the database
  147. from which data will be dumped.
  148. .. django-admin-option:: --natural
  149. .. versionadded:: 1.2
  150. Use :ref:`natural keys <topics-serialization-natural-keys>` to represent
  151. any foreign key and many-to-many relationship with a model that provides
  152. a natural key definition. If you are dumping ``contrib.auth`` ``Permission``
  153. objects or ``contrib.contenttypes`` ``ContentType`` objects, you should
  154. probably be using this flag.
  155. flush
  156. -----
  157. .. django-admin:: flush
  158. Returns the database to the state it was in immediately after syncdb was
  159. executed. This means that all data will be removed from the database, any
  160. post-synchronization handlers will be re-executed, and the ``initial_data``
  161. fixture will be re-installed.
  162. The :djadminopt:`--noinput` option may be provided to suppress all user
  163. prompts.
  164. .. versionadded:: 1.2
  165. The :djadminopt:`--database` option may be used to specify the database
  166. to flush.
  167. inspectdb
  168. ---------
  169. .. django-admin:: inspectdb
  170. Introspects the database tables in the database pointed-to by the
  171. :setting:`NAME` setting and outputs a Django model module (a ``models.py``
  172. file) to standard output.
  173. Use this if you have a legacy database with which you'd like to use Django.
  174. The script will inspect the database and create a model for each table within
  175. it.
  176. As you might expect, the created models will have an attribute for every field
  177. in the table. Note that ``inspectdb`` has a few special cases in its field-name
  178. output:
  179. * If ``inspectdb`` cannot map a column's type to a model field type, it'll
  180. use ``TextField`` and will insert the Python comment
  181. ``'This field type is a guess.'`` next to the field in the generated
  182. model.
  183. * If the database column name is a Python reserved word (such as
  184. ``'pass'``, ``'class'`` or ``'for'``), ``inspectdb`` will append
  185. ``'_field'`` to the attribute name. For example, if a table has a column
  186. ``'for'``, the generated model will have a field ``'for_field'``, with
  187. the ``db_column`` attribute set to ``'for'``. ``inspectdb`` will insert
  188. the Python comment
  189. ``'Field renamed because it was a Python reserved word.'`` next to the
  190. field.
  191. This feature is meant as a shortcut, not as definitive model generation. After
  192. you run it, you'll want to look over the generated models yourself to make
  193. customizations. In particular, you'll need to rearrange models' order, so that
  194. models that refer to other models are ordered properly.
  195. Primary keys are automatically introspected for PostgreSQL, MySQL and
  196. SQLite, in which case Django puts in the ``primary_key=True`` where
  197. needed.
  198. ``inspectdb`` works with PostgreSQL, MySQL and SQLite. Foreign-key detection
  199. only works in PostgreSQL and with certain types of MySQL tables.
  200. .. versionadded:: 1.2
  201. The :djadminopt:`--database` option may be used to specify the
  202. database to introspect.
  203. loaddata <fixture fixture ...>
  204. ------------------------------
  205. .. django-admin:: loaddata
  206. Searches for and loads the contents of the named fixture into the database.
  207. .. versionadded:: 1.2
  208. The :djadminopt:`--database` option can be used to specify the database
  209. onto which the data will be loaded.
  210. What's a "fixture"?
  211. ~~~~~~~~~~~~~~~~~~~
  212. A *fixture* is a collection of files that contain the serialized contents of
  213. the database. Each fixture has a unique name, and the files that comprise the
  214. fixture can be distributed over multiple directories, in multiple applications.
  215. Django will search in three locations for fixtures:
  216. 1. In the ``fixtures`` directory of every installed application
  217. 2. In any directory named in the :setting:`FIXTURE_DIRS` setting
  218. 3. In the literal path named by the fixture
  219. Django will load any and all fixtures it finds in these locations that match
  220. the provided fixture names.
  221. If the named fixture has a file extension, only fixtures of that type
  222. will be loaded. For example::
  223. django-admin.py loaddata mydata.json
  224. would only load JSON fixtures called ``mydata``. The fixture extension
  225. must correspond to the registered name of a
  226. :ref:`serializer <serialization-formats>` (e.g., ``json`` or ``xml``).
  227. If you omit the extensions, Django will search all available fixture types
  228. for a matching fixture. For example::
  229. django-admin.py loaddata mydata
  230. would look for any fixture of any fixture type called ``mydata``. If a fixture
  231. directory contained ``mydata.json``, that fixture would be loaded
  232. as a JSON fixture.
  233. The fixtures that are named can include directory components. These
  234. directories will be included in the search path. For example::
  235. django-admin.py loaddata foo/bar/mydata.json
  236. would search ``<appname>/fixtures/foo/bar/mydata.json`` for each installed
  237. application, ``<dirname>/foo/bar/mydata.json`` for each directory in
  238. :setting:`FIXTURE_DIRS`, and the literal path ``foo/bar/mydata.json``.
  239. When fixture files are processed, the data is saved to the database as is.
  240. Model defined ``save`` methods and ``pre_save`` signals are not called.
  241. Note that the order in which fixture files are processed is undefined. However,
  242. all fixture data is installed as a single transaction, so data in
  243. one fixture can reference data in another fixture. If the database backend
  244. supports row-level constraints, these constraints will be checked at the
  245. end of the transaction.
  246. The ``dumpdata`` command can be used to generate input for ``loaddata``.
  247. Compressed fixtures
  248. ~~~~~~~~~~~~~~~~~~~
  249. Fixtures may be compressed in ``zip``, ``gz``, or ``bz2`` format. For example::
  250. django-admin.py loaddata mydata.json
  251. would look for any of ``mydata.json``, ``mydata.json.zip``,
  252. ``mydata.json.gz``, or ``mydata.json.bz2``. The first file contained within a
  253. zip-compressed archive is used.
  254. Note that if two fixtures with the same name but different
  255. fixture type are discovered (for example, if ``mydata.json`` and
  256. ``mydata.xml.gz`` were found in the same fixture directory), fixture
  257. installation will be aborted, and any data installed in the call to
  258. ``loaddata`` will be removed from the database.
  259. .. admonition:: MySQL with MyISAM and fixtures
  260. The MyISAM storage engine of MySQL doesn't support transactions or
  261. constraints, so if you use MyISAM, you won't get validation of fixture
  262. data, or a rollback if multiple transaction files are found.
  263. Database-specific fixtures
  264. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  265. If you're in a multi-database setup, you might have fixture data that
  266. you want to load onto one database, but not onto another. In this
  267. situation, you can add database identifier into the names of your fixtures.
  268. For example, if your :setting:`DATABASES` setting has a 'master' database
  269. defined, name the fixture ``mydata.master.json`` or
  270. ``mydata.master.json.gz`` and the fixture will only be loaded when you
  271. specify you want to load data into the ``master`` database.
  272. makemessages
  273. ------------
  274. .. django-admin:: makemessages
  275. Runs over the entire source tree of the current directory and pulls out all
  276. strings marked for translation. It creates (or updates) a message file in the
  277. conf/locale (in the django tree) or locale (for project and application)
  278. directory. After making changes to the messages files you need to compile them
  279. with ``compilemessages`` for use with the builtin gettext support. See the
  280. :ref:`i18n documentation <how-to-create-language-files>` for details.
  281. .. django-admin-option:: --all
  282. Use the ``--all`` or ``-a`` option to update the message files for all
  283. available languages.
  284. Example usage::
  285. django-admin.py makemessages --all
  286. .. django-admin-option:: --extension
  287. Use the ``--extension`` or ``-e`` option to specify a list of file extensions
  288. to examine (default: ".html", ".txt").
  289. Example usage::
  290. django-admin.py makemessages --locale=de --extension xhtml
  291. Separate multiple extensions with commas or use -e or --extension multiple times::
  292. django-admin.py makemessages --locale=de --extension=html,txt --extension xml
  293. Use the :djadminopt:`--locale` option to specify the locale to process.
  294. Example usage::
  295. django-admin.py makemessages --locale=br_PT
  296. .. django-admin-option:: --domain
  297. Use the ``--domain`` or ``-d`` option to change the domain of the messages files.
  298. Currently supported:
  299. * ``django`` for all ``*.py``, ``*.html`` and ``*.txt`` files (default)
  300. * ``djangojs`` for ``*.js`` files
  301. .. django-admin-option:: --symlinks
  302. .. versionadded:: 1.2
  303. Use the ``--symlinks`` or ``-s`` option to follow symlinks to directories when
  304. looking for new translation strings.
  305. Example usage::
  306. django-admin.py makemessages --locale=de --symlinks
  307. .. django-admin-option:: --ignore
  308. Use the ``--ignore`` or ``-i`` option to ignore files or directories matching
  309. the given :mod:`glob`-style pattern. Use multiple times to ignore more.
  310. These patterns are used by default: ``'CVS'``, ``'.*'``, ``'*~'``
  311. Example usage::
  312. django-admin.py makemessages --locale=en_US --ignore=apps/* --ignore=secret/*.html
  313. .. django-admin-option:: --no-default-ignore
  314. Use the ``--no-default-ignore`` option to disable the default values of
  315. :djadminopt:`--ignore`.
  316. .. django-admin-option:: --no-wrap
  317. .. versionadded:: 1.3
  318. Use the ``--no-wrap`` option to disable breaking long message lines into
  319. several lines in language files.
  320. .. django-admin-option:: --no-location
  321. .. versionadded:: 1.4
  322. Use the ``--no-location`` option to not write '``#: filename:line``'
  323. comment lines in language files. Note that using this option makes it harder
  324. for technically skilled translators to understand each message's context.
  325. runfcgi [options]
  326. -----------------
  327. .. django-admin:: runfcgi
  328. Starts a set of FastCGI processes suitable for use with any Web server that
  329. supports the FastCGI protocol. See the :doc:`FastCGI deployment documentation
  330. </howto/deployment/fastcgi>` for details. Requires the Python FastCGI module from
  331. `flup`_.
  332. .. versionadded:: 1.4
  333. Internally, this wraps the WSGI application object specified by the
  334. :setting:`WSGI_APPLICATION` setting.
  335. .. _flup: http://www.saddi.com/software/flup/
  336. The options accepted by this command are passed to the FastCGI library and
  337. don't use the ``'--'`` prefix as is usual for other Django management commands.
  338. .. django-admin-option:: protocol
  339. ``protocol=PROTOCOL``
  340. Protocol to use. *PROTOCOL* can be ``fcgi``, ``scgi``, ``ajp``, etc.
  341. (default is ``fcgi``)
  342. .. django-admin-option:: host
  343. ``host=HOSTNAME``
  344. Hostname to listen on.
  345. .. django-admin-option:: port
  346. ``port=PORTNUM``
  347. Port to listen on.
  348. .. django-admin-option:: socket
  349. ``socket=FILE``
  350. UNIX socket to listen on.
  351. .. django-admin-option:: method
  352. ``method=IMPL``
  353. Possible values: ``prefork`` or ``threaded`` (default ``prefork``)
  354. .. django-admin-option:: maxrequests
  355. ``maxrequests=NUMBER``
  356. Number of requests a child handles before it is killed and a new child is
  357. forked (0 means no limit).
  358. .. django-admin-option:: maxspare
  359. ``maxspare=NUMBER``
  360. Max number of spare processes / threads.
  361. .. django-admin-option:: minspare
  362. ``minspare=NUMBER``
  363. Min number of spare processes / threads.
  364. .. django-admin-option:: maxchildren
  365. ``maxchildren=NUMBER``
  366. Hard limit number of processes / threads.
  367. .. django-admin-option:: daemonize
  368. ``daemonize=BOOL``
  369. Whether to detach from terminal.
  370. .. django-admin-option:: pidfile
  371. ``pidfile=FILE``
  372. Write the spawned process-id to file *FILE*.
  373. .. django-admin-option:: workdir
  374. ``workdir=DIRECTORY``
  375. Change to directory *DIRECTORY* when daemonizing.
  376. .. django-admin-option:: debug
  377. ``debug=BOOL``
  378. Set to true to enable flup tracebacks.
  379. .. django-admin-option:: outlog
  380. ``outlog=FILE``
  381. Write stdout to the *FILE* file.
  382. .. django-admin-option:: errlog
  383. ``errlog=FILE``
  384. Write stderr to the *FILE* file.
  385. .. django-admin-option:: umask
  386. ``umask=UMASK``
  387. Umask to use when daemonizing. The value is interpeted as an octal number
  388. (default value is ``022``).
  389. Example usage::
  390. django-admin.py runfcgi socket=/tmp/fcgi.sock method=prefork daemonize=true \
  391. pidfile=/var/run/django-fcgi.pid
  392. Run a FastCGI server as a daemon and write the spawned PID in a file.
  393. runserver [port or address:port]
  394. --------------------------------
  395. .. django-admin:: runserver
  396. Starts a lightweight development Web server on the local machine. By default,
  397. the server runs on port 8000 on the IP address ``127.0.0.1``. You can pass in an
  398. IP address and port number explicitly.
  399. If you run this script as a user with normal privileges (recommended), you
  400. might not have access to start a port on a low port number. Low port numbers
  401. are reserved for the superuser (root).
  402. .. versionadded:: 1.4
  403. This server uses the WSGI application object specified by the
  404. :setting:`WSGI_APPLICATION` setting.
  405. DO NOT USE THIS SERVER IN A PRODUCTION SETTING. It has not gone through
  406. security audits or performance tests. (And that's how it's gonna stay. We're in
  407. the business of making Web frameworks, not Web servers, so improving this
  408. server to be able to handle a production environment is outside the scope of
  409. Django.)
  410. The development server automatically reloads Python code for each request, as
  411. needed. You don't need to restart the server for code changes to take effect.
  412. When you start the server, and each time you change Python code while the
  413. server is running, the server will validate all of your installed models. (See
  414. the ``validate`` command below.) If the validator finds errors, it will print
  415. them to standard output, but it won't stop the server.
  416. You can run as many servers as you want, as long as they're on separate ports.
  417. Just execute ``django-admin.py runserver`` more than once.
  418. Note that the default IP address, ``127.0.0.1``, is not accessible from other
  419. machines on your network. To make your development server viewable to other
  420. machines on the network, use its own IP address (e.g. ``192.168.2.1``) or
  421. ``0.0.0.0`` or ``::`` (with IPv6 enabled).
  422. .. versionchanged:: 1.3
  423. You can provide an IPv6 address surrounded by brackets
  424. (e.g. ``[200a::1]:8000``). This will automatically enable IPv6 support.
  425. A hostname containing ASCII-only characters can also be used.
  426. .. versionchanged:: 1.3
  427. If the :doc:`staticfiles</ref/contrib/staticfiles>` contrib app is enabled
  428. (default in new projects) the :djadmin:`runserver` command will be overriden
  429. with an own :djadmin:`runserver<staticfiles-runserver>` command.
  430. .. django-admin-option:: --noreload
  431. Use the ``--noreload`` option to disable the use of the auto-reloader. This
  432. means any Python code changes you make while the server is running will *not*
  433. take effect if the particular Python modules have already been loaded into
  434. memory.
  435. Example usage::
  436. django-admin.py runserver --noreload
  437. .. django-admin-option:: --nothreading
  438. .. versionadded:: 1.4
  439. Use the ``--nothreading`` option to disable the use of threading in the
  440. development server.
  441. .. django-admin-option:: --ipv6, -6
  442. .. versionadded:: 1.3
  443. Use the ``--ipv6`` (or shorter ``-6``) option to tell Django to use IPv6 for
  444. the development server. This changes the default IP address from
  445. ``127.0.0.1`` to ``::1``.
  446. Example usage::
  447. django-admin.py runserver --ipv6
  448. Examples of using different ports and addresses
  449. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  450. Port 8000 on IP address ``127.0.0.1``::
  451. django-admin.py runserver
  452. Port 8000 on IP address ``1.2.3.4``::
  453. django-admin.py runserver 1.2.3.4:8000
  454. Port 7000 on IP address ``127.0.0.1``::
  455. django-admin.py runserver 7000
  456. Port 7000 on IP address ``1.2.3.4``::
  457. django-admin.py runserver 1.2.3.4:7000
  458. Port 8000 on IPv6 address ``::1``::
  459. django-admin.py runserver -6
  460. Port 7000 on IPv6 address ``::1``::
  461. django-admin.py runserver -6 7000
  462. Port 7000 on IPv6 address ``2001:0db8:1234:5678::9``::
  463. django-admin.py runserver [2001:0db8:1234:5678::9]:7000
  464. Port 8000 on IPv4 address of host ``localhost``::
  465. django-admin.py runserver localhost:8000
  466. Port 8000 on IPv6 address of host ``localhost``::
  467. django-admin.py runserver -6 localhost:8000
  468. Serving static files with the development server
  469. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  470. By default, the development server doesn't serve any static files for your site
  471. (such as CSS files, images, things under :setting:`MEDIA_URL` and so forth). If
  472. you want to configure Django to serve static media, read :doc:`/howto/static-files`.
  473. shell
  474. -----
  475. .. django-admin:: shell
  476. Starts the Python interactive interpreter.
  477. Django will use IPython_ or bpython_ if either is installed. If you have a
  478. rich shell installed but want to force use of the "plain" Python interpreter,
  479. use the ``--plain`` option, like so::
  480. django-admin.py shell --plain
  481. .. _IPython: http://ipython.scipy.org/
  482. .. _bpython: http://bpython-interpreter.org/
  483. sql <appname appname ...>
  484. -------------------------
  485. .. django-admin:: sql
  486. Prints the CREATE TABLE SQL statements for the given app name(s).
  487. .. versionadded:: 1.2
  488. The :djadminopt:`--database` option can be used to specify the database for
  489. which to print the SQL.
  490. sqlall <appname appname ...>
  491. ----------------------------
  492. .. django-admin:: sqlall
  493. Prints the CREATE TABLE and initial-data SQL statements for the given app name(s).
  494. Refer to the description of ``sqlcustom`` for an explanation of how to
  495. specify initial data.
  496. .. versionadded:: 1.2
  497. The :djadminopt:`--database` option can be used to specify the database for
  498. which to print the SQL.
  499. sqlclear <appname appname ...>
  500. ------------------------------
  501. .. django-admin:: sqlclear
  502. Prints the DROP TABLE SQL statements for the given app name(s).
  503. .. versionadded:: 1.2
  504. The :djadminopt:`--database` option can be used to specify the database for
  505. which to print the SQL.
  506. sqlcustom <appname appname ...>
  507. -------------------------------
  508. .. django-admin:: sqlcustom
  509. Prints the custom SQL statements for the given app name(s).
  510. For each model in each specified app, this command looks for the file
  511. ``<appname>/sql/<modelname>.sql``, where ``<appname>`` is the given app name and
  512. ``<modelname>`` is the model's name in lowercase. For example, if you have an
  513. app ``news`` that includes a ``Story`` model, ``sqlcustom`` will attempt
  514. to read a file ``news/sql/story.sql`` and append it to the output of this
  515. command.
  516. Each of the SQL files, if given, is expected to contain valid SQL. The SQL
  517. files are piped directly into the database after all of the models'
  518. table-creation statements have been executed. Use this SQL hook to make any
  519. table modifications, or insert any SQL functions into the database.
  520. Note that the order in which the SQL files are processed is undefined.
  521. .. versionadded:: 1.2
  522. The :djadminopt:`--database` option can be used to specify the database for
  523. which to print the SQL.
  524. sqlflush
  525. --------
  526. .. django-admin:: sqlflush
  527. Prints the SQL statements that would be executed for the :djadmin:`flush`
  528. command.
  529. .. versionadded:: 1.2
  530. The :djadminopt:`--database` option can be used to specify the database for
  531. which to print the SQL.
  532. sqlindexes <appname appname ...>
  533. --------------------------------
  534. .. django-admin:: sqlindexes
  535. Prints the CREATE INDEX SQL statements for the given app name(s).
  536. .. versionadded:: 1.2
  537. The :djadminopt:`--database` option can be used to specify the database for
  538. which to print the SQL.
  539. sqlsequencereset <appname appname ...>
  540. --------------------------------------
  541. .. django-admin:: sqlsequencereset
  542. Prints the SQL statements for resetting sequences for the given app name(s).
  543. Sequences are indexes used by some database engines to track the next available
  544. number for automatically incremented fields.
  545. Use this command to generate SQL which will fix cases where a sequence is out
  546. of sync with its automatically incremented field data.
  547. .. versionadded:: 1.2
  548. The :djadminopt:`--database` option can be used to specify the database for
  549. which to print the SQL.
  550. startapp <appname> [destination]
  551. --------------------------------
  552. .. django-admin:: startapp
  553. Creates a Django app directory structure for the given app name in the current
  554. directory or the given destination.
  555. .. versionchanged:: 1.4
  556. By default the directory created contains a ``models.py`` file and other app
  557. template files. (See the `source`_ for more details.) If only the app
  558. name is given, the app directory will be created in the current working
  559. directory.
  560. If the optional destination is provided, Django will use that existing
  561. directory rather than creating a new one. You can use '.' to denote the current
  562. working directory.
  563. For example::
  564. django-admin.py startapp myapp /Users/jezdez/Code/myapp
  565. .. versionadded:: 1.4
  566. .. django-admin-option:: --template
  567. With the ``--template`` option, you can use a custom app template by providing
  568. either the path to a directory with the app template file, or a path to a
  569. compressed file (``.tar.gz``, ``.tar.bz2``, ``.tgz``, ``.tbz``, ``.zip``)
  570. containing the app template files.
  571. Django will also accept URLs (``http``, ``https``, ``ftp``) to compressed
  572. archives with the app template files, downloading and extracting them on the
  573. fly.
  574. For example, this would look for an app template in the given directory when
  575. creating the ``myapp`` app::
  576. django-admin.py startapp --template=/Users/jezdez/Code/my_app_template myapp
  577. .. versionadded:: 1.4
  578. When Django copies the app template files, it also renders certain files
  579. through the template engine: the files whose extensions match the
  580. ``--extension`` option (``py`` by default) and the files whose names are passed
  581. with the ``--name`` option. The :class:`template context
  582. <django.template.Context>` used is:
  583. - Any option passed to the startapp command
  584. - ``app_name`` -- the app name as passed to the command
  585. - ``app_directory`` -- the full path of the newly created app
  586. .. _render_warning:
  587. .. warning::
  588. When the app template files are rendered with the Django template
  589. engine (by default all ``*.py`` files), Django will also replace all
  590. stray template variables contained. For example, if one of the Python files
  591. contains a docstring explaining a particular feature related
  592. to template rendering, it might result in an incorrect example.
  593. To work around this problem, you can use the :ttag:`templatetag`
  594. templatetag to "escape" the various parts of the template syntax.
  595. .. _source: https://github.com/django/django/tree/master/django/conf/app_template/
  596. startproject <projectname> [destination]
  597. ----------------------------------------
  598. .. django-admin:: startproject
  599. Creates a Django project directory structure for the given project name in
  600. the current directory or the given destination.
  601. .. versionchanged:: 1.4
  602. By default, the new directory contains ``manage.py`` and a project package
  603. (containing a ``settings.py`` and other files). See the `template source`_ for
  604. details.
  605. If only the project name is given, both the project directory and project
  606. package will be named ``<projectname>`` and the project directory
  607. will be created in the current working directory.
  608. If the optional destination is provided, Django will use that existing
  609. directory as the project directory, and create ``manage.py`` and the project
  610. package within it. Use '.' to denote the current working directory.
  611. For example::
  612. django-admin.py startproject myproject /Users/jezdez/Code/myproject_repo
  613. .. versionadded:: 1.4
  614. As with the :djadmin:`startapp` command, the ``--template`` option lets you
  615. specify a directory, file path or URL of a custom project template. See the
  616. :djadmin:`startapp` documentation for details of supported project template
  617. formats.
  618. For example, this would look for a project template in the given directory
  619. when creating the ``myproject`` project::
  620. django-admin.py startproject --template=/Users/jezdez/Code/my_project_template myproject
  621. When Django copies the project template files, it also renders certain files
  622. through the template engine: the files whose extensions match the
  623. ``--extension`` option (``py`` by default) and the files whose names are passed
  624. with the ``--name`` option. The :class:`template context
  625. <django.template.Context>` used is:
  626. - Any option passed to the startproject command
  627. - ``project_name`` -- the project name as passed to the command
  628. - ``project_directory`` -- the full path of the newly created project
  629. - ``secret_key`` -- a random key for the :setting:`SECRET_KEY` setting
  630. Please also see the :ref:`rendering warning <render_warning>` as mentioned
  631. for :djadmin:`startapp`.
  632. .. _`template source`: https://github.com/django/django/tree/master/django/conf/project_template/
  633. syncdb
  634. ------
  635. .. django-admin:: syncdb
  636. Creates the database tables for all apps in :setting:`INSTALLED_APPS` whose
  637. tables have not already been created.
  638. Use this command when you've added new applications to your project and want to
  639. install them in the database. This includes any apps shipped with Django that
  640. might be in :setting:`INSTALLED_APPS` by default. When you start a new project,
  641. run this command to install the default apps.
  642. .. admonition:: Syncdb will not alter existing tables
  643. ``syncdb`` will only create tables for models which have not yet been
  644. installed. It will *never* issue ``ALTER TABLE`` statements to match
  645. changes made to a model class after installation. Changes to model classes
  646. and database schemas often involve some form of ambiguity and, in those
  647. cases, Django would have to guess at the correct changes to make. There is
  648. a risk that critical data would be lost in the process.
  649. If you have made changes to a model and wish to alter the database tables
  650. to match, use the ``sql`` command to display the new SQL structure and
  651. compare that to your existing table schema to work out the changes.
  652. If you're installing the ``django.contrib.auth`` application, ``syncdb`` will
  653. give you the option of creating a superuser immediately.
  654. ``syncdb`` will also search for and install any fixture named ``initial_data``
  655. with an appropriate extension (e.g. ``json`` or ``xml``). See the
  656. documentation for ``loaddata`` for details on the specification of fixture
  657. data files.
  658. The :djadminopt:`--noinput` option may be provided to suppress all user
  659. prompts.
  660. .. versionadded:: 1.2
  661. The :djadminopt:`--database` option can be used to specify the database to
  662. synchronize.
  663. test <app or test identifier>
  664. -----------------------------
  665. .. django-admin:: test
  666. Runs tests for all installed models. See :doc:`/topics/testing` for more
  667. information.
  668. .. versionadded:: 1.2
  669. .. django-admin-option:: --failfast
  670. The ``--failfast`` option can be used to stop running tests and report the
  671. failure immediately after a test fails.
  672. .. versionadded:: 1.4
  673. .. django-admin-option:: --testrunner
  674. The ``--testrunner`` option can be used to control the test runner class that
  675. is used to execute tests. If this value is provided, it overrides the value
  676. provided by the :setting:`TEST_RUNNER` setting.
  677. .. versionadded:: 1.4
  678. .. django-admin-option:: --liveserver
  679. The ``--liveserver`` option can be used to override the default address where
  680. the live server (used with :class:`~django.test.LiveServerTestCase`) is
  681. expected to run from. The default value is ``localhost:8081``.
  682. testserver <fixture fixture ...>
  683. --------------------------------
  684. .. django-admin:: testserver
  685. Runs a Django development server (as in ``runserver``) using data from the
  686. given fixture(s).
  687. For example, this command::
  688. django-admin.py testserver mydata.json
  689. ...would perform the following steps:
  690. 1. Create a test database, as described in :doc:`/topics/testing`.
  691. 2. Populate the test database with fixture data from the given fixtures.
  692. (For more on fixtures, see the documentation for ``loaddata`` above.)
  693. 3. Runs the Django development server (as in ``runserver``), pointed at
  694. this newly created test database instead of your production database.
  695. This is useful in a number of ways:
  696. * When you're writing :doc:`unit tests </topics/testing>` of how your views
  697. act with certain fixture data, you can use ``testserver`` to interact with
  698. the views in a Web browser, manually.
  699. * Let's say you're developing your Django application and have a "pristine"
  700. copy of a database that you'd like to interact with. You can dump your
  701. database to a fixture (using the ``dumpdata`` command, explained above),
  702. then use ``testserver`` to run your Web application with that data. With
  703. this arrangement, you have the flexibility of messing up your data
  704. in any way, knowing that whatever data changes you're making are only
  705. being made to a test database.
  706. Note that this server does *not* automatically detect changes to your Python
  707. source code (as ``runserver`` does). It does, however, detect changes to
  708. templates.
  709. .. django-admin-option:: --addrport [port number or ipaddr:port]
  710. Use ``--addrport`` to specify a different port, or IP address and port, from
  711. the default of ``127.0.0.1:8000``. This value follows exactly the same format and
  712. serves exactly the same function as the argument to the ``runserver`` command.
  713. Examples:
  714. To run the test server on port 7000 with ``fixture1`` and ``fixture2``::
  715. django-admin.py testserver --addrport 7000 fixture1 fixture2
  716. django-admin.py testserver fixture1 fixture2 --addrport 7000
  717. (The above statements are equivalent. We include both of them to demonstrate
  718. that it doesn't matter whether the options come before or after the fixture
  719. arguments.)
  720. To run on 1.2.3.4:7000 with a ``test`` fixture::
  721. django-admin.py testserver --addrport 1.2.3.4:7000 test
  722. .. versionadded:: 1.3
  723. The :djadminopt:`--noinput` option may be provided to suppress all user
  724. prompts.
  725. validate
  726. --------
  727. .. django-admin:: validate
  728. Validates all installed models (according to the :setting:`INSTALLED_APPS`
  729. setting) and prints validation errors to standard output.
  730. Commands provided by applications
  731. =================================
  732. Some commands are only available when the ``django.contrib`` application that
  733. :doc:`implements </howto/custom-management-commands>` them has been
  734. :setting:`enabled <INSTALLED_APPS>`. This section describes them grouped by
  735. their application.
  736. ``django.contrib.auth``
  737. -----------------------
  738. changepassword
  739. ~~~~~~~~~~~~~~
  740. .. django-admin:: changepassword
  741. .. versionadded:: 1.2
  742. This command is only available if Django's :doc:`authentication system
  743. </topics/auth>` (``django.contrib.auth``) is installed.
  744. Allows changing a user's password. It prompts you to enter twice the password of
  745. the user given as parameter. If they both match, the new password will be
  746. changed immediately. If you do not supply a user, the command will attempt to
  747. change the password whose username matches the current user.
  748. .. versionadded:: 1.4
  749. Use the ``--database`` option to specify the database to query for the user. If
  750. it's not supplied, Django will use the ``default`` database.
  751. Example usage::
  752. django-admin.py changepassword ringo
  753. createsuperuser
  754. ~~~~~~~~~~~~~~~
  755. .. django-admin:: createsuperuser
  756. This command is only available if Django's :doc:`authentication system
  757. </topics/auth>` (``django.contrib.auth``) is installed.
  758. Creates a superuser account (a user who has all permissions). This is
  759. useful if you need to create an initial superuser account but did not
  760. do so during ``syncdb``, or if you need to programmatically generate
  761. superuser accounts for your site(s).
  762. When run interactively, this command will prompt for a password for
  763. the new superuser account. When run non-interactively, no password
  764. will be set, and the superuser account will not be able to log in until
  765. a password has been manually set for it.
  766. .. django-admin-option:: --username
  767. .. django-admin-option:: --email
  768. The username and email address for the new account can be supplied by
  769. using the ``--username`` and ``--email`` arguments on the command
  770. line. If either of those is not supplied, ``createsuperuser`` will prompt for
  771. it when running interactively.
  772. .. versionadded:: 1.4
  773. Use the ``--database`` option to specify the database into which the superuser
  774. object will be saved.
  775. ``django.contrib.gis``
  776. ----------------------
  777. ogrinspect
  778. ~~~~~~~~~~
  779. This command is only available if :doc:`GeoDjango </ref/contrib/gis/index>`
  780. (``django.contrib.gis``) is installed.
  781. Please refer to its :djadmin:`description <ogrinspect>` in the GeoDjango
  782. documentation.
  783. ``django.contrib.sitemaps``
  784. ---------------------------
  785. ping_google
  786. ~~~~~~~~~~~
  787. This command is only available if the :doc:`Sitemaps framework
  788. </ref/contrib/sitemaps>` (``django.contrib.sitemaps``) is installed.
  789. Please refer to its :djadmin:`description <ping_google>` in the Sitemaps
  790. documentation.
  791. ``django.contrib.staticfiles``
  792. ------------------------------
  793. collectstatic
  794. ~~~~~~~~~~~~~
  795. This command is only available if the :doc:`static files application
  796. </howto/static-files>` (``django.contrib.staticfiles``) is installed.
  797. Please refer to its :djadmin:`description <collectstatic>` in the
  798. :doc:`staticfiles </ref/contrib/staticfiles>` documentation.
  799. findstatic
  800. ~~~~~~~~~~
  801. This command is only available if the :doc:`static files application
  802. </howto/static-files>` (``django.contrib.staticfiles``) is installed.
  803. Please refer to its :djadmin:`description <findstatic>` in the :doc:`staticfiles
  804. </ref/contrib/staticfiles>` documentation.
  805. Default options
  806. ===============
  807. Although some commands may allow their own custom options, every command
  808. allows for the following options:
  809. .. django-admin-option:: --pythonpath
  810. Example usage::
  811. django-admin.py syncdb --pythonpath='/home/djangoprojects/myproject'
  812. Adds the given filesystem path to the Python `import search path`_. If this
  813. isn't provided, ``django-admin.py`` will use the ``PYTHONPATH`` environment
  814. variable.
  815. Note that this option is unnecessary in ``manage.py``, because it takes care of
  816. setting the Python path for you.
  817. .. _import search path: http://diveintopython.net/getting_to_know_python/everything_is_an_object.html
  818. .. django-admin-option:: --settings
  819. Example usage::
  820. django-admin.py syncdb --settings=mysite.settings
  821. Explicitly specifies the settings module to use. The settings module should be
  822. in Python package syntax, e.g. ``mysite.settings``. If this isn't provided,
  823. ``django-admin.py`` will use the ``DJANGO_SETTINGS_MODULE`` environment
  824. variable.
  825. Note that this option is unnecessary in ``manage.py``, because it uses
  826. ``settings.py`` from the current project by default.
  827. .. django-admin-option:: --traceback
  828. Example usage::
  829. django-admin.py syncdb --traceback
  830. By default, ``django-admin.py`` will show a simple error message whenever an
  831. error occurs. If you specify ``--traceback``, ``django-admin.py`` will
  832. output a full stack trace whenever an exception is raised.
  833. .. django-admin-option:: --verbosity
  834. Example usage::
  835. django-admin.py syncdb --verbosity 2
  836. Use ``--verbosity`` to specify the amount of notification and debug information
  837. that ``django-admin.py`` should print to the console.
  838. * ``0`` means no output.
  839. * ``1`` means normal output (default).
  840. * ``2`` means verbose output.
  841. * ``3`` means *very* verbose output.
  842. Common options
  843. ==============
  844. The following options are not available on every command, but they are common
  845. to a number of commands.
  846. .. django-admin-option:: --database
  847. .. versionadded:: 1.2
  848. Used to specify the database on which a command will operate. If not
  849. specified, this option will default to an alias of ``default``.
  850. For example, to dump data from the database with the alias ``master``::
  851. django-admin.py dumpdata --database=master
  852. .. django-admin-option:: --exclude
  853. Exclude a specific application from the applications whose contents is
  854. output. For example, to specifically exclude the `auth` application from
  855. the output of dumpdata, you would call::
  856. django-admin.py dumpdata --exclude=auth
  857. If you want to exclude multiple applications, use multiple ``--exclude``
  858. directives::
  859. django-admin.py dumpdata --exclude=auth --exclude=contenttypes
  860. .. django-admin-option:: --locale
  861. Use the ``--locale`` or ``-l`` option to specify the locale to process.
  862. If not provided all locales are processed.
  863. .. django-admin-option:: --noinput
  864. Use the ``--noinput`` option to suppress all user prompting, such as "Are
  865. you sure?" confirmation messages. This is useful if ``django-admin.py`` is
  866. being executed as an unattended, automated script.
  867. Extra niceties
  868. ==============
  869. .. _syntax-coloring:
  870. Syntax coloring
  871. ---------------
  872. The ``django-admin.py`` / ``manage.py`` commands will use pretty
  873. color-coded output if your terminal supports ANSI-colored output. It
  874. won't use the color codes if you're piping the command's output to
  875. another program.
  876. The colors used for syntax highlighting can be customized. Django
  877. ships with three color palettes:
  878. * ``dark``, suited to terminals that show white text on a black
  879. background. This is the default palette.
  880. * ``light``, suited to terminals that show black text on a white
  881. background.
  882. * ``nocolor``, which disables syntax highlighting.
  883. You select a palette by setting a ``DJANGO_COLORS`` environment
  884. variable to specify the palette you want to use. For example, to
  885. specify the ``light`` palette under a Unix or OS/X BASH shell, you
  886. would run the following at a command prompt::
  887. export DJANGO_COLORS="light"
  888. You can also customize the colors that are used. Django specifies a
  889. number of roles in which color is used:
  890. * ``error`` - A major error.
  891. * ``notice`` - A minor error.
  892. * ``sql_field`` - The name of a model field in SQL.
  893. * ``sql_coltype`` - The type of a model field in SQL.
  894. * ``sql_keyword`` - A SQL keyword.
  895. * ``sql_table`` - The name of a model in SQL.
  896. * ``http_info`` - A 1XX HTTP Informational server response.
  897. * ``http_success`` - A 2XX HTTP Success server response.
  898. * ``http_not_modified`` - A 304 HTTP Not Modified server response.
  899. * ``http_redirect`` - A 3XX HTTP Redirect server response other than 304.
  900. * ``http_not_found`` - A 404 HTTP Not Found server response.
  901. * ``http_bad_request`` - A 4XX HTTP Bad Request server response other than 404.
  902. * ``http_server_error`` - A 5XX HTTP Server Error response.
  903. Each of these roles can be assigned a specific foreground and
  904. background color, from the following list:
  905. * ``black``
  906. * ``red``
  907. * ``green``
  908. * ``yellow``
  909. * ``blue``
  910. * ``magenta``
  911. * ``cyan``
  912. * ``white``
  913. Each of these colors can then be modified by using the following
  914. display options:
  915. * ``bold``
  916. * ``underscore``
  917. * ``blink``
  918. * ``reverse``
  919. * ``conceal``
  920. A color specification follows one of the following patterns:
  921. * ``role=fg``
  922. * ``role=fg/bg``
  923. * ``role=fg,option,option``
  924. * ``role=fg/bg,option,option``
  925. where ``role`` is the name of a valid color role, ``fg`` is the
  926. foreground color, ``bg`` is the background color and each ``option``
  927. is one of the color modifying options. Multiple color specifications
  928. are then separated by semicolon. For example::
  929. export DJANGO_COLORS="error=yellow/blue,blink;notice=magenta"
  930. would specify that errors be displayed using blinking yellow on blue,
  931. and notices displayed using magenta. All other color roles would be
  932. left uncolored.
  933. Colors can also be specified by extending a base palette. If you put
  934. a palette name in a color specification, all the colors implied by that
  935. palette will be loaded. So::
  936. export DJANGO_COLORS="light;error=yellow/blue,blink;notice=magenta"
  937. would specify the use of all the colors in the light color palette,
  938. *except* for the colors for errors and notices which would be
  939. overridden as specified.
  940. Bash completion
  941. ---------------
  942. If you use the Bash shell, consider installing the Django bash completion
  943. script, which lives in ``extras/django_bash_completion`` in the Django
  944. distribution. It enables tab-completion of ``django-admin.py`` and
  945. ``manage.py`` commands, so you can, for instance...
  946. * Type ``django-admin.py``.
  947. * Press [TAB] to see all available options.
  948. * Type ``sql``, then [TAB], to see all available options whose names start
  949. with ``sql``.
  950. See :doc:`/howto/custom-management-commands` for how to add customized actions.
  951. ==========================================
  952. Running management commands from your code
  953. ==========================================
  954. .. _call-command:
  955. .. function:: django.core.management.call_command(name, *args, **options)
  956. To call a management command from code use ``call_command``.
  957. ``name``
  958. the name of the command to call.
  959. ``*args``
  960. a list of arguments accepted by the command.
  961. ``**options``
  962. named options accepted on the command-line.
  963. Examples::
  964. from django.core import management
  965. management.call_command('flush', verbosity=0, interactive=False)
  966. management.call_command('loaddata', 'test_data', verbosity=0)