django-admin.1 64 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271
  1. .\" Man page generated from reStructuredText.
  2. .
  3. .TH "DJANGO-ADMIN" "1" "March 07, 2015" "1.9" "Django"
  4. .SH NAME
  5. django-admin \- Utility script for the Django Web framework
  6. .
  7. .nr rst2man-indent-level 0
  8. .
  9. .de1 rstReportMargin
  10. \\$1 \\n[an-margin]
  11. level \\n[rst2man-indent-level]
  12. level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
  13. -
  14. \\n[rst2man-indent0]
  15. \\n[rst2man-indent1]
  16. \\n[rst2man-indent2]
  17. ..
  18. .de1 INDENT
  19. .\" .rstReportMargin pre:
  20. . RS \\$1
  21. . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
  22. . nr rst2man-indent-level +1
  23. .\" .rstReportMargin post:
  24. ..
  25. .de UNINDENT
  26. . RE
  27. .\" indent \\n[an-margin]
  28. .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
  29. .nr rst2man-indent-level -1
  30. .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
  31. .in \\n[rst2man-indent\\n[rst2man-indent-level]]u
  32. ..
  33. .sp
  34. \fBdjango\-admin\fP is Django\(aqs command\-line utility for administrative tasks.
  35. This document outlines all it can do.
  36. .sp
  37. In addition, \fBmanage.py\fP is automatically created in each Django project.
  38. \fBmanage.py\fP is a thin wrapper around \fBdjango\-admin\fP that takes care of
  39. several things for you before delegating to \fBdjango\-admin\fP:
  40. .INDENT 0.0
  41. .IP \(bu 2
  42. It puts your project\(aqs package on \fBsys.path\fP\&.
  43. .IP \(bu 2
  44. It sets the \fBDJANGO_SETTINGS_MODULE\fP environment variable so that
  45. it points to your project\(aqs \fBsettings.py\fP file.
  46. .IP \(bu 2
  47. It calls \fBdjango.setup()\fP to initialize various internals of Django.
  48. .UNINDENT
  49. .sp
  50. The \fBdjango\-admin\fP script should be on your system path if you installed
  51. Django via its \fBsetup.py\fP utility. If it\(aqs not on your path, you can find it
  52. in \fBsite\-packages/django/bin\fP within your Python installation. Consider
  53. symlinking it from some place on your path, such as \fB/usr/local/bin\fP\&.
  54. .sp
  55. For Windows users, who do not have symlinking functionality available, you can
  56. copy \fBdjango\-admin.exe\fP to a location on your existing path or edit the
  57. \fBPATH\fP settings (under \fBSettings \- Control Panel \- System \- Advanced \-
  58. Environment...\fP) to point to its installed location.
  59. .sp
  60. Generally, when working on a single Django project, it\(aqs easier to use
  61. \fBmanage.py\fP than \fBdjango\-admin\fP\&. If you need to switch between multiple
  62. Django settings files, use \fBdjango\-admin\fP with
  63. \fBDJANGO_SETTINGS_MODULE\fP or the \fI\%\-\-settings\fP command line
  64. option.
  65. .sp
  66. The command\-line examples throughout this document use \fBdjango\-admin\fP to
  67. be consistent, but any example can use \fBmanage.py\fP just as well.
  68. .SH USAGE
  69. .INDENT 0.0
  70. .INDENT 3.5
  71. .sp
  72. .nf
  73. .ft C
  74. $ django\-admin <command> [options]
  75. $ manage.py <command> [options]
  76. .ft P
  77. .fi
  78. .UNINDENT
  79. .UNINDENT
  80. .sp
  81. \fBcommand\fP should be one of the commands listed in this document.
  82. \fBoptions\fP, which is optional, should be zero or more of the options available
  83. for the given command.
  84. .SS Getting runtime help
  85. .INDENT 0.0
  86. .TP
  87. .B django\-admin help
  88. .UNINDENT
  89. .sp
  90. Run \fBdjango\-admin help\fP to display usage information and a list of the
  91. commands provided by each application.
  92. .sp
  93. Run \fBdjango\-admin help \-\-commands\fP to display a list of all available
  94. commands.
  95. .sp
  96. Run \fBdjango\-admin help <command>\fP to display a description of the given
  97. command and a list of its available options.
  98. .SS App names
  99. .sp
  100. Many commands take a list of "app names." An "app name" is the basename of
  101. the package containing your models. For example, if your \fBINSTALLED_APPS\fP
  102. contains the string \fB\(aqmysite.blog\(aq\fP, the app name is \fBblog\fP\&.
  103. .SS Determining the version
  104. .INDENT 0.0
  105. .TP
  106. .B django\-admin version
  107. .UNINDENT
  108. .sp
  109. Run \fBdjango\-admin version\fP to display the current Django version.
  110. .sp
  111. The output follows the schema described in \fI\%PEP 386\fP:
  112. .INDENT 0.0
  113. .INDENT 3.5
  114. .sp
  115. .nf
  116. .ft C
  117. 1.4.dev17026
  118. 1.4a1
  119. 1.4
  120. .ft P
  121. .fi
  122. .UNINDENT
  123. .UNINDENT
  124. .SS Displaying debug output
  125. .sp
  126. Use \fI\%\-\-verbosity\fP to specify the amount of notification and debug information
  127. that \fBdjango\-admin\fP should print to the console. For more details, see the
  128. documentation for the \fI\%\-\-verbosity\fP option.
  129. .SH AVAILABLE COMMANDS
  130. .SS check <appname appname ...>
  131. .INDENT 0.0
  132. .TP
  133. .B django\-admin check
  134. .UNINDENT
  135. .sp
  136. Uses the \fBsystem check framework\fP to inspect
  137. the entire Django project for common problems.
  138. .sp
  139. The system check framework will confirm that there aren\(aqt any problems with
  140. your installed models or your admin registrations. It will also provide warnings
  141. of common compatibility problems introduced by upgrading Django to a new version.
  142. Custom checks may be introduced by other libraries and applications.
  143. .sp
  144. By default, all apps will be checked. You can check a subset of apps by providing
  145. a list of app labels as arguments:
  146. .INDENT 0.0
  147. .INDENT 3.5
  148. .sp
  149. .nf
  150. .ft C
  151. python manage.py check auth admin myapp
  152. .ft P
  153. .fi
  154. .UNINDENT
  155. .UNINDENT
  156. .sp
  157. If you do not specify any app, all apps will be checked.
  158. .INDENT 0.0
  159. .TP
  160. .B \-\-tag <tagname>
  161. .UNINDENT
  162. .sp
  163. The \fBsystem check framework\fP performs many different
  164. types of checks. These check types are categorized with tags. You can use these tags
  165. to restrict the checks performed to just those in a particular category. For example,
  166. to perform only security and compatibility checks, you would run:
  167. .INDENT 0.0
  168. .INDENT 3.5
  169. .sp
  170. .nf
  171. .ft C
  172. python manage.py check \-\-tag security \-\-tag compatibility
  173. .ft P
  174. .fi
  175. .UNINDENT
  176. .UNINDENT
  177. .INDENT 0.0
  178. .TP
  179. .B \-\-list\-tags
  180. .UNINDENT
  181. .sp
  182. List all available tags.
  183. .INDENT 0.0
  184. .TP
  185. .B \-\-deploy
  186. .UNINDENT
  187. .sp
  188. .sp
  189. The \fB\-\-deploy\fP option activates some additional checks that are only relevant
  190. in a deployment setting.
  191. .sp
  192. You can use this option in your local development environment, but since your
  193. local development settings module may not have many of your production settings,
  194. you will probably want to point the \fBcheck\fP command at a different settings
  195. module, either by setting the \fBDJANGO_SETTINGS_MODULE\fP environment variable,
  196. or by passing the \fB\-\-settings\fP option:
  197. .INDENT 0.0
  198. .INDENT 3.5
  199. .sp
  200. .nf
  201. .ft C
  202. python manage.py check \-\-deploy \-\-settings=production_settings
  203. .ft P
  204. .fi
  205. .UNINDENT
  206. .UNINDENT
  207. .sp
  208. Or you could run it directly on a production or staging deployment to verify
  209. that the correct settings are in use (omitting \fB\-\-settings\fP). You could even
  210. make it part of your integration test suite.
  211. .SS compilemessages
  212. .INDENT 0.0
  213. .TP
  214. .B django\-admin compilemessages
  215. .UNINDENT
  216. .sp
  217. Compiles .po files created by \fI\%makemessages\fP to .mo files for use with
  218. the builtin gettext support. See \fB/topics/i18n/index\fP\&.
  219. .sp
  220. Use the \fI\%\-\-locale\fP option (or its shorter version \fB\-l\fP) to
  221. specify the locale(s) to process. If not provided, all locales are processed.
  222. .sp
  223. Use the \fI\%\-\-exclude\fP option (or its shorter version \fB\-x\fP) to
  224. specify the locale(s) to exclude from processing. If not provided, no locales
  225. are excluded.
  226. .sp
  227. You can pass \fB\-\-use\-fuzzy\fP option (or \fB\-f\fP) to include fuzzy translations
  228. into compiled files.
  229. .sp
  230. Added \fB\-\-exclude\fP and \fB\-\-use\-fuzzy\fP options.
  231. .sp
  232. Example usage:
  233. .INDENT 0.0
  234. .INDENT 3.5
  235. .sp
  236. .nf
  237. .ft C
  238. django\-admin compilemessages \-\-locale=pt_BR
  239. django\-admin compilemessages \-\-locale=pt_BR \-\-locale=fr \-f
  240. django\-admin compilemessages \-l pt_BR
  241. django\-admin compilemessages \-l pt_BR \-l fr \-\-use\-fuzzy
  242. django\-admin compilemessages \-\-exclude=pt_BR
  243. django\-admin compilemessages \-\-exclude=pt_BR \-\-exclude=fr
  244. django\-admin compilemessages \-x pt_BR
  245. django\-admin compilemessages \-x pt_BR \-x fr
  246. .ft P
  247. .fi
  248. .UNINDENT
  249. .UNINDENT
  250. .SS createcachetable
  251. .INDENT 0.0
  252. .TP
  253. .B django\-admin createcachetable
  254. .UNINDENT
  255. .sp
  256. Creates the cache tables for use with the database cache backend using the
  257. information from your settings file. See \fB/topics/cache\fP for more
  258. information.
  259. .sp
  260. The \fI\%\-\-database\fP option can be used to specify the database
  261. onto which the cache table will be installed, but since this information is
  262. pulled from your settings by default, it\(aqs typically not needed.
  263. .SS dbshell
  264. .INDENT 0.0
  265. .TP
  266. .B django\-admin dbshell
  267. .UNINDENT
  268. .sp
  269. Runs the command\-line client for the database engine specified in your
  270. \fBENGINE\fP setting, with the connection parameters specified in your
  271. \fBUSER\fP, \fBPASSWORD\fP, etc., settings.
  272. .INDENT 0.0
  273. .IP \(bu 2
  274. For PostgreSQL, this runs the \fBpsql\fP command\-line client.
  275. .IP \(bu 2
  276. For MySQL, this runs the \fBmysql\fP command\-line client.
  277. .IP \(bu 2
  278. For SQLite, this runs the \fBsqlite3\fP command\-line client.
  279. .UNINDENT
  280. .sp
  281. This command assumes the programs are on your \fBPATH\fP so that a simple call to
  282. the program name (\fBpsql\fP, \fBmysql\fP, \fBsqlite3\fP) will find the program in
  283. the right place. There\(aqs no way to specify the location of the program
  284. manually.
  285. .sp
  286. The \fI\%\-\-database\fP option can be used to specify the database
  287. onto which to open a shell.
  288. .SS diffsettings
  289. .INDENT 0.0
  290. .TP
  291. .B django\-admin diffsettings
  292. .UNINDENT
  293. .sp
  294. Displays differences between the current settings file and Django\(aqs default
  295. settings.
  296. .sp
  297. Settings that don\(aqt appear in the defaults are followed by \fB"###"\fP\&. For
  298. example, the default settings don\(aqt define \fBROOT_URLCONF\fP, so
  299. \fBROOT_URLCONF\fP is followed by \fB"###"\fP in the output of
  300. \fBdiffsettings\fP\&.
  301. .sp
  302. The \fI\%\-\-all\fP option may be provided to display all settings, even
  303. if they have Django\(aqs default value. Such settings are prefixed by \fB"###"\fP\&.
  304. .SS dumpdata <app_label app_label app_label.Model ...>
  305. .INDENT 0.0
  306. .TP
  307. .B django\-admin dumpdata
  308. .UNINDENT
  309. .sp
  310. Outputs to standard output all data in the database associated with the named
  311. application(s).
  312. .sp
  313. If no application name is provided, all installed applications will be dumped.
  314. .sp
  315. The output of \fBdumpdata\fP can be used as input for \fI\%loaddata\fP\&.
  316. .sp
  317. Note that \fBdumpdata\fP uses the default manager on the model for selecting the
  318. records to dump. If you\(aqre using a \fIcustom manager\fP as
  319. the default manager and it filters some of the available records, not all of the
  320. objects will be dumped.
  321. .sp
  322. The \fI\%\-\-all\fP option may be provided to specify that
  323. \fBdumpdata\fP should use Django\(aqs base manager, dumping records which
  324. might otherwise be filtered or modified by a custom manager.
  325. .INDENT 0.0
  326. .TP
  327. .B \-\-format <fmt>
  328. .UNINDENT
  329. .sp
  330. By default, \fBdumpdata\fP will format its output in JSON, but you can use the
  331. \fB\-\-format\fP option to specify another format. Currently supported formats
  332. are listed in \fIserialization\-formats\fP\&.
  333. .INDENT 0.0
  334. .TP
  335. .B \-\-indent <num>
  336. .UNINDENT
  337. .sp
  338. By default, \fBdumpdata\fP will output all data on a single line. This isn\(aqt
  339. easy for humans to read, so you can use the \fB\-\-indent\fP option to
  340. pretty\-print the output with a number of indentation spaces.
  341. .sp
  342. The \fI\%\-\-exclude\fP option may be provided to prevent specific
  343. applications or models (specified as in the form of \fBapp_label.ModelName\fP)
  344. from being dumped. If you specify a model name to \fBdumpdata\fP, the dumped
  345. output will be restricted to that model, rather than the entire application.
  346. You can also mix application names and model names.
  347. .sp
  348. The \fI\%\-\-database\fP option can be used to specify the database
  349. from which data will be dumped.
  350. .INDENT 0.0
  351. .TP
  352. .B \-\-natural\-foreign
  353. .UNINDENT
  354. .sp
  355. When this option is specified, Django will use the \fBnatural_key()\fP model
  356. method to serialize any foreign key and many\-to\-many relationship to objects of
  357. the type that defines the method. If you are dumping \fBcontrib.auth\fP
  358. \fBPermission\fP objects or \fBcontrib.contenttypes\fP \fBContentType\fP objects, you
  359. should probably be using this flag. See the \fInatural keys\fP documentation for more details on this
  360. and the next option.
  361. .INDENT 0.0
  362. .TP
  363. .B \-\-natural\-primary
  364. .UNINDENT
  365. .sp
  366. When this option is specified, Django will not provide the primary key in the
  367. serialized data of this object since it can be calculated during
  368. deserialization.
  369. .INDENT 0.0
  370. .TP
  371. .B \-\-pks
  372. .UNINDENT
  373. .sp
  374. By default, \fBdumpdata\fP will output all the records of the model, but
  375. you can use the \fB\-\-pks\fP option to specify a comma separated list of
  376. primary keys on which to filter. This is only available when dumping
  377. one model.
  378. .INDENT 0.0
  379. .TP
  380. .B \-\-output
  381. .UNINDENT
  382. .sp
  383. .sp
  384. By default \fBdumpdata\fP will output all the serialized data to standard output.
  385. This options allows to specify the file to which the data is to be written.
  386. .SS flush
  387. .INDENT 0.0
  388. .TP
  389. .B django\-admin flush
  390. .UNINDENT
  391. .sp
  392. Removes all data from the database, re\-executes any post\-synchronization
  393. handlers, and reinstalls any initial data fixtures.
  394. .sp
  395. The \fI\%\-\-noinput\fP option may be provided to suppress all user
  396. prompts.
  397. .sp
  398. The \fI\%\-\-database\fP option may be used to specify the database
  399. to flush.
  400. .SS inspectdb
  401. .INDENT 0.0
  402. .TP
  403. .B django\-admin inspectdb
  404. .UNINDENT
  405. .sp
  406. Introspects the database tables and views in the database pointed\-to by the
  407. \fBNAME\fP setting and outputs a Django model module (a \fBmodels.py\fP
  408. file) to standard output.
  409. .sp
  410. Use this if you have a legacy database with which you\(aqd like to use Django.
  411. The script will inspect the database and create a model for each table or view
  412. within it.
  413. .sp
  414. As you might expect, the created models will have an attribute for every field
  415. in the table or view. Note that \fBinspectdb\fP has a few special cases in its
  416. field\-name output:
  417. .INDENT 0.0
  418. .IP \(bu 2
  419. If \fBinspectdb\fP cannot map a column\(aqs type to a model field type, it\(aqll
  420. use \fBTextField\fP and will insert the Python comment
  421. \fB\(aqThis field type is a guess.\(aq\fP next to the field in the generated
  422. model.
  423. .IP \(bu 2
  424. If the database column name is a Python reserved word (such as
  425. \fB\(aqpass\(aq\fP, \fB\(aqclass\(aq\fP or \fB\(aqfor\(aq\fP), \fBinspectdb\fP will append
  426. \fB\(aq_field\(aq\fP to the attribute name. For example, if a table has a column
  427. \fB\(aqfor\(aq\fP, the generated model will have a field \fB\(aqfor_field\(aq\fP, with
  428. the \fBdb_column\fP attribute set to \fB\(aqfor\(aq\fP\&. \fBinspectdb\fP will insert
  429. the Python comment
  430. \fB\(aqField renamed because it was a Python reserved word.\(aq\fP next to the
  431. field.
  432. .UNINDENT
  433. .sp
  434. This feature is meant as a shortcut, not as definitive model generation. After
  435. you run it, you\(aqll want to look over the generated models yourself to make
  436. customizations. In particular, you\(aqll need to rearrange models\(aq order, so that
  437. models that refer to other models are ordered properly.
  438. .sp
  439. Primary keys are automatically introspected for PostgreSQL, MySQL and
  440. SQLite, in which case Django puts in the \fBprimary_key=True\fP where
  441. needed.
  442. .sp
  443. \fBinspectdb\fP works with PostgreSQL, MySQL and SQLite. Foreign\-key detection
  444. only works in PostgreSQL and with certain types of MySQL tables.
  445. .sp
  446. Django doesn\(aqt create database defaults when a
  447. \fBdefault\fP is specified on a model field.
  448. Similarly, database defaults aren\(aqt translated to model field defaults or
  449. detected in any fashion by \fBinspectdb\fP\&.
  450. .sp
  451. By default, \fBinspectdb\fP creates unmanaged models. That is, \fBmanaged = False\fP
  452. in the model\(aqs \fBMeta\fP class tells Django not to manage each table\(aqs creation,
  453. modification, and deletion. If you do want to allow Django to manage the
  454. table\(aqs lifecycle, you\(aqll need to change the
  455. \fBmanaged\fP option to \fBTrue\fP (or simply remove
  456. it because \fBTrue\fP is its default value).
  457. .sp
  458. The \fI\%\-\-database\fP option may be used to specify the
  459. database to introspect.
  460. .sp
  461. A feature to inspect database views was added. In previous versions, only
  462. tables (not views) were inspected.
  463. .SS loaddata <fixture fixture ...>
  464. .INDENT 0.0
  465. .TP
  466. .B django\-admin loaddata
  467. .UNINDENT
  468. .sp
  469. Searches for and loads the contents of the named fixture into the database.
  470. .sp
  471. The \fI\%\-\-database\fP option can be used to specify the database
  472. onto which the data will be loaded.
  473. .INDENT 0.0
  474. .TP
  475. .B \-\-ignorenonexistent
  476. .UNINDENT
  477. .sp
  478. The \fI\%\-\-ignorenonexistent\fP option can be used to ignore fields and
  479. models that may have been removed since the fixture was originally generated.
  480. .INDENT 0.0
  481. .TP
  482. .B \-\-app
  483. .UNINDENT
  484. .sp
  485. The \fI\%\-\-app\fP option can be used to specify a single app to look
  486. for fixtures in rather than looking through all apps.
  487. .sp
  488. \fB\-\-ignorenonexistent\fP also ignores non\-existent models.
  489. .SS What\(aqs a "fixture"?
  490. .sp
  491. A \fIfixture\fP is a collection of files that contain the serialized contents of
  492. the database. Each fixture has a unique name, and the files that comprise the
  493. fixture can be distributed over multiple directories, in multiple applications.
  494. .sp
  495. Django will search in three locations for fixtures:
  496. .INDENT 0.0
  497. .IP 1. 3
  498. In the \fBfixtures\fP directory of every installed application
  499. .IP 2. 3
  500. In any directory named in the \fBFIXTURE_DIRS\fP setting
  501. .IP 3. 3
  502. In the literal path named by the fixture
  503. .UNINDENT
  504. .sp
  505. Django will load any and all fixtures it finds in these locations that match
  506. the provided fixture names.
  507. .sp
  508. If the named fixture has a file extension, only fixtures of that type
  509. will be loaded. For example:
  510. .INDENT 0.0
  511. .INDENT 3.5
  512. .sp
  513. .nf
  514. .ft C
  515. django\-admin loaddata mydata.json
  516. .ft P
  517. .fi
  518. .UNINDENT
  519. .UNINDENT
  520. .sp
  521. would only load JSON fixtures called \fBmydata\fP\&. The fixture extension
  522. must correspond to the registered name of a
  523. \fIserializer\fP (e.g., \fBjson\fP or \fBxml\fP).
  524. .sp
  525. If you omit the extensions, Django will search all available fixture types
  526. for a matching fixture. For example:
  527. .INDENT 0.0
  528. .INDENT 3.5
  529. .sp
  530. .nf
  531. .ft C
  532. django\-admin loaddata mydata
  533. .ft P
  534. .fi
  535. .UNINDENT
  536. .UNINDENT
  537. .sp
  538. would look for any fixture of any fixture type called \fBmydata\fP\&. If a fixture
  539. directory contained \fBmydata.json\fP, that fixture would be loaded
  540. as a JSON fixture.
  541. .sp
  542. The fixtures that are named can include directory components. These
  543. directories will be included in the search path. For example:
  544. .INDENT 0.0
  545. .INDENT 3.5
  546. .sp
  547. .nf
  548. .ft C
  549. django\-admin loaddata foo/bar/mydata.json
  550. .ft P
  551. .fi
  552. .UNINDENT
  553. .UNINDENT
  554. .sp
  555. would search \fB<app_label>/fixtures/foo/bar/mydata.json\fP for each installed
  556. application, \fB<dirname>/foo/bar/mydata.json\fP for each directory in
  557. \fBFIXTURE_DIRS\fP, and the literal path \fBfoo/bar/mydata.json\fP\&.
  558. .sp
  559. When fixture files are processed, the data is saved to the database as is.
  560. Model defined \fBsave()\fP methods are not called, and
  561. any \fBpre_save\fP or
  562. \fBpost_save\fP signals will be called with
  563. \fBraw=True\fP since the instance only contains attributes that are local to the
  564. model. You may, for example, want to disable handlers that access
  565. related fields that aren\(aqt present during fixture loading and would otherwise
  566. raise an exception:
  567. .INDENT 0.0
  568. .INDENT 3.5
  569. .sp
  570. .nf
  571. .ft C
  572. from django.db.models.signals import post_save
  573. from .models import MyModel
  574. def my_handler(**kwargs):
  575. # disable the handler during fixture loading
  576. if kwargs[\(aqraw\(aq]:
  577. return
  578. ...
  579. post_save.connect(my_handler, sender=MyModel)
  580. .ft P
  581. .fi
  582. .UNINDENT
  583. .UNINDENT
  584. .sp
  585. You could also write a simple decorator to encapsulate this logic:
  586. .INDENT 0.0
  587. .INDENT 3.5
  588. .sp
  589. .nf
  590. .ft C
  591. from functools import wraps
  592. def disable_for_loaddata(signal_handler):
  593. """
  594. Decorator that turns off signal handlers when loading fixture data.
  595. """
  596. @wraps(signal_handler)
  597. def wrapper(*args, **kwargs):
  598. if kwargs[\(aqraw\(aq]:
  599. return
  600. signal_handler(*args, **kwargs)
  601. return wrapper
  602. @disable_for_loaddata
  603. def my_handler(**kwargs):
  604. ...
  605. .ft P
  606. .fi
  607. .UNINDENT
  608. .UNINDENT
  609. .sp
  610. Just be aware that this logic will disable the signals whenever fixtures are
  611. deserialized, not just during \fBloaddata\fP\&.
  612. .sp
  613. Note that the order in which fixture files are processed is undefined. However,
  614. all fixture data is installed as a single transaction, so data in
  615. one fixture can reference data in another fixture. If the database backend
  616. supports row\-level constraints, these constraints will be checked at the
  617. end of the transaction.
  618. .sp
  619. The \fI\%dumpdata\fP command can be used to generate input for \fBloaddata\fP\&.
  620. .SS Compressed fixtures
  621. .sp
  622. Fixtures may be compressed in \fBzip\fP, \fBgz\fP, or \fBbz2\fP format. For example:
  623. .INDENT 0.0
  624. .INDENT 3.5
  625. .sp
  626. .nf
  627. .ft C
  628. django\-admin loaddata mydata.json
  629. .ft P
  630. .fi
  631. .UNINDENT
  632. .UNINDENT
  633. .sp
  634. would look for any of \fBmydata.json\fP, \fBmydata.json.zip\fP,
  635. \fBmydata.json.gz\fP, or \fBmydata.json.bz2\fP\&. The first file contained within a
  636. zip\-compressed archive is used.
  637. .sp
  638. Note that if two fixtures with the same name but different
  639. fixture type are discovered (for example, if \fBmydata.json\fP and
  640. \fBmydata.xml.gz\fP were found in the same fixture directory), fixture
  641. installation will be aborted, and any data installed in the call to
  642. \fBloaddata\fP will be removed from the database.
  643. .INDENT 0.0
  644. .INDENT 3.5
  645. .IP "MySQL with MyISAM and fixtures"
  646. .sp
  647. The MyISAM storage engine of MySQL doesn\(aqt support transactions or
  648. constraints, so if you use MyISAM, you won\(aqt get validation of fixture
  649. data, or a rollback if multiple transaction files are found.
  650. .UNINDENT
  651. .UNINDENT
  652. .SS Database\-specific fixtures
  653. .sp
  654. If you\(aqre in a multi\-database setup, you might have fixture data that
  655. you want to load onto one database, but not onto another. In this
  656. situation, you can add database identifier into the names of your fixtures.
  657. .sp
  658. For example, if your \fBDATABASES\fP setting has a \(aqmaster\(aq database
  659. defined, name the fixture \fBmydata.master.json\fP or
  660. \fBmydata.master.json.gz\fP and the fixture will only be loaded when you
  661. specify you want to load data into the \fBmaster\fP database.
  662. .SS makemessages
  663. .INDENT 0.0
  664. .TP
  665. .B django\-admin makemessages
  666. .UNINDENT
  667. .sp
  668. Runs over the entire source tree of the current directory and pulls out all
  669. strings marked for translation. It creates (or updates) a message file in the
  670. conf/locale (in the Django tree) or locale (for project and application)
  671. directory. After making changes to the messages files you need to compile them
  672. with \fI\%compilemessages\fP for use with the builtin gettext support. See
  673. the \fIi18n documentation\fP for details.
  674. .INDENT 0.0
  675. .TP
  676. .B \-\-all
  677. .UNINDENT
  678. .sp
  679. Use the \fB\-\-all\fP or \fB\-a\fP option to update the message files for all
  680. available languages.
  681. .sp
  682. Example usage:
  683. .INDENT 0.0
  684. .INDENT 3.5
  685. .sp
  686. .nf
  687. .ft C
  688. django\-admin makemessages \-\-all
  689. .ft P
  690. .fi
  691. .UNINDENT
  692. .UNINDENT
  693. .INDENT 0.0
  694. .TP
  695. .B \-\-extension
  696. .UNINDENT
  697. .sp
  698. Use the \fB\-\-extension\fP or \fB\-e\fP option to specify a list of file extensions
  699. to examine (default: ".html", ".txt").
  700. .sp
  701. Example usage:
  702. .INDENT 0.0
  703. .INDENT 3.5
  704. .sp
  705. .nf
  706. .ft C
  707. django\-admin makemessages \-\-locale=de \-\-extension xhtml
  708. .ft P
  709. .fi
  710. .UNINDENT
  711. .UNINDENT
  712. .sp
  713. Separate multiple extensions with commas or use \-e or \-\-extension multiple times:
  714. .INDENT 0.0
  715. .INDENT 3.5
  716. .sp
  717. .nf
  718. .ft C
  719. django\-admin makemessages \-\-locale=de \-\-extension=html,txt \-\-extension xml
  720. .ft P
  721. .fi
  722. .UNINDENT
  723. .UNINDENT
  724. .sp
  725. Use the \fI\%\-\-locale\fP option (or its shorter version \fB\-l\fP) to
  726. specify the locale(s) to process.
  727. .sp
  728. .sp
  729. Use the \fI\%\-\-exclude\fP option (or its shorter version \fB\-x\fP) to
  730. specify the locale(s) to exclude from processing. If not provided, no locales
  731. are excluded.
  732. .sp
  733. Example usage:
  734. .INDENT 0.0
  735. .INDENT 3.5
  736. .sp
  737. .nf
  738. .ft C
  739. django\-admin makemessages \-\-locale=pt_BR
  740. django\-admin makemessages \-\-locale=pt_BR \-\-locale=fr
  741. django\-admin makemessages \-l pt_BR
  742. django\-admin makemessages \-l pt_BR \-l fr
  743. django\-admin makemessages \-\-exclude=pt_BR
  744. django\-admin makemessages \-\-exclude=pt_BR \-\-exclude=fr
  745. django\-admin makemessages \-x pt_BR
  746. django\-admin makemessages \-x pt_BR \-x fr
  747. .ft P
  748. .fi
  749. .UNINDENT
  750. .UNINDENT
  751. .INDENT 0.0
  752. .TP
  753. .B \-\-domain
  754. .UNINDENT
  755. .sp
  756. Use the \fB\-\-domain\fP or \fB\-d\fP option to change the domain of the messages files.
  757. Currently supported:
  758. .INDENT 0.0
  759. .IP \(bu 2
  760. \fBdjango\fP for all \fB*.py\fP, \fB*.html\fP and \fB*.txt\fP files (default)
  761. .IP \(bu 2
  762. \fBdjangojs\fP for \fB*.js\fP files
  763. .UNINDENT
  764. .INDENT 0.0
  765. .TP
  766. .B \-\-symlinks
  767. .UNINDENT
  768. .sp
  769. Use the \fB\-\-symlinks\fP or \fB\-s\fP option to follow symlinks to directories when
  770. looking for new translation strings.
  771. .sp
  772. Example usage:
  773. .INDENT 0.0
  774. .INDENT 3.5
  775. .sp
  776. .nf
  777. .ft C
  778. django\-admin makemessages \-\-locale=de \-\-symlinks
  779. .ft P
  780. .fi
  781. .UNINDENT
  782. .UNINDENT
  783. .INDENT 0.0
  784. .TP
  785. .B \-\-ignore
  786. .UNINDENT
  787. .sp
  788. Use the \fB\-\-ignore\fP or \fB\-i\fP option to ignore files or directories matching
  789. the given \fI\%glob\fP\-style pattern. Use multiple times to ignore more.
  790. .sp
  791. These patterns are used by default: \fB\(aqCVS\(aq\fP, \fB\(aq.*\(aq\fP, \fB\(aq*~\(aq\fP, \fB\(aq*.pyc\(aq\fP
  792. .sp
  793. Example usage:
  794. .INDENT 0.0
  795. .INDENT 3.5
  796. .sp
  797. .nf
  798. .ft C
  799. django\-admin makemessages \-\-locale=en_US \-\-ignore=apps/* \-\-ignore=secret/*.html
  800. .ft P
  801. .fi
  802. .UNINDENT
  803. .UNINDENT
  804. .INDENT 0.0
  805. .TP
  806. .B \-\-no\-default\-ignore
  807. .UNINDENT
  808. .sp
  809. Use the \fB\-\-no\-default\-ignore\fP option to disable the default values of
  810. \fI\%\-\-ignore\fP\&.
  811. .INDENT 0.0
  812. .TP
  813. .B \-\-no\-wrap
  814. .UNINDENT
  815. .sp
  816. Use the \fB\-\-no\-wrap\fP option to disable breaking long message lines into
  817. several lines in language files.
  818. .INDENT 0.0
  819. .TP
  820. .B \-\-no\-location
  821. .UNINDENT
  822. .sp
  823. Use the \fB\-\-no\-location\fP option to not write \(aq\fB#: filename:line\fP
  824. comment lines in language files. Note that using this option makes it harder
  825. for technically skilled translators to understand each message\(aqs context.
  826. .INDENT 0.0
  827. .TP
  828. .B \-\-keep\-pot
  829. .UNINDENT
  830. .sp
  831. Use the \fB\-\-keep\-pot\fP option to prevent Django from deleting the temporary
  832. .pot files it generates before creating the .po file. This is useful for
  833. debugging errors which may prevent the final language files from being created.
  834. .sp
  835. \fBSEE ALSO:\fP
  836. .INDENT 0.0
  837. .INDENT 3.5
  838. See \fIcustomizing\-makemessages\fP for instructions on how to customize
  839. the keywords that \fI\%makemessages\fP passes to \fBxgettext\fP\&.
  840. .UNINDENT
  841. .UNINDENT
  842. .SS makemigrations [<app_label>]
  843. .INDENT 0.0
  844. .TP
  845. .B django\-admin makemigrations
  846. .UNINDENT
  847. .sp
  848. Creates new migrations based on the changes detected to your models.
  849. Migrations, their relationship with apps and more are covered in depth in
  850. \fBthe migrations documentation\fP\&.
  851. .sp
  852. Providing one or more app names as arguments will limit the migrations created
  853. to the app(s) specified and any dependencies needed (the table at the other end
  854. of a \fBForeignKey\fP, for example).
  855. .INDENT 0.0
  856. .TP
  857. .B \-\-empty
  858. .UNINDENT
  859. .sp
  860. The \fB\-\-empty\fP option will cause \fBmakemigrations\fP to output an empty
  861. migration for the specified apps, for manual editing. This option is only
  862. for advanced users and should not be used unless you are familiar with
  863. the migration format, migration operations, and the dependencies between
  864. your migrations.
  865. .INDENT 0.0
  866. .TP
  867. .B \-\-dry\-run
  868. .UNINDENT
  869. .sp
  870. The \fB\-\-dry\-run\fP option shows what migrations would be made without
  871. actually writing any migrations files to disk. Using this option along with
  872. \fB\-\-verbosity 3\fP will also show the complete migrations files that would be
  873. written.
  874. .INDENT 0.0
  875. .TP
  876. .B \-\-merge
  877. .UNINDENT
  878. .sp
  879. The \fB\-\-merge\fP option enables fixing of migration conflicts. The
  880. \fI\%\-\-noinput\fP option may be provided to suppress user prompts during
  881. a merge.
  882. .INDENT 0.0
  883. .TP
  884. .B \-\-name, \-n
  885. .UNINDENT
  886. .sp
  887. .sp
  888. The \fB\-\-name\fP option allows you to give the migration(s) a custom name instead
  889. of a generated one.
  890. .INDENT 0.0
  891. .TP
  892. .B \-\-exit, \-e
  893. .UNINDENT
  894. .sp
  895. .sp
  896. The \fB\-\-exit\fP option will cause \fBmakemigrations\fP to exit with error code 1
  897. when no migration are created (or would have been created, if combined with
  898. \fB\-\-dry\-run\fP).
  899. .SS migrate [<app_label> [<migrationname>]]
  900. .INDENT 0.0
  901. .TP
  902. .B django\-admin migrate
  903. .UNINDENT
  904. .sp
  905. Synchronizes the database state with the current set of models and migrations.
  906. Migrations, their relationship with apps and more are covered in depth in
  907. \fBthe migrations documentation\fP\&.
  908. .sp
  909. The behavior of this command changes depending on the arguments provided:
  910. .INDENT 0.0
  911. .IP \(bu 2
  912. No arguments: All apps have all of their migrations run.
  913. .IP \(bu 2
  914. \fB<app_label>\fP: The specified app has its migrations run, up to the most
  915. recent migration. This may involve running other apps\(aq migrations too, due
  916. to dependencies.
  917. .IP \(bu 2
  918. \fB<app_label> <migrationname>\fP: Brings the database schema to a state where
  919. the named migration is applied, but no later migrations in the same app are
  920. applied. This may involve unapplying migrations if you have previously
  921. migrated past the named migration. Use the name \fBzero\fP to unapply all
  922. migrations for an app.
  923. .UNINDENT
  924. .sp
  925. The \fI\%\-\-database\fP option can be used to specify the database to
  926. migrate.
  927. .INDENT 0.0
  928. .TP
  929. .B \-\-fake
  930. .UNINDENT
  931. .sp
  932. The \fB\-\-fake\fP option tells Django to mark the migrations as having been
  933. applied or unapplied, but without actually running the SQL to change your
  934. database schema.
  935. .sp
  936. This is intended for advanced users to manipulate the
  937. current migration state directly if they\(aqre manually applying changes;
  938. be warned that using \fB\-\-fake\fP runs the risk of putting the migration state
  939. table into a state where manual recovery will be needed to make migrations
  940. run correctly.
  941. .sp
  942. .INDENT 0.0
  943. .TP
  944. .B \-\-fake\-initial
  945. .UNINDENT
  946. .sp
  947. The \fB\-\-fake\-initial\fP option can be used to allow Django to skip an app\(aqs
  948. initial migration if all database tables with the names of all models created
  949. by all \fBCreateModel\fP operations in that
  950. migration already exist. This option is intended for use when first running
  951. migrations against a database that preexisted the use of migrations. This
  952. option does not, however, check for matching database schema beyond matching
  953. table names and so is only safe to use if you are confident that your existing
  954. schema matches what is recorded in your initial migration.
  955. .sp
  956. Deprecated since version 1.8: The \fB\-\-list\fP option has been moved to the \fI\%showmigrations\fP
  957. command.
  958. .SS runserver [port or address:port]
  959. .INDENT 0.0
  960. .TP
  961. .B django\-admin runserver
  962. .UNINDENT
  963. .sp
  964. Starts a lightweight development Web server on the local machine. By default,
  965. the server runs on port 8000 on the IP address \fB127.0.0.1\fP\&. You can pass in an
  966. IP address and port number explicitly.
  967. .sp
  968. If you run this script as a user with normal privileges (recommended), you
  969. might not have access to start a port on a low port number. Low port numbers
  970. are reserved for the superuser (root).
  971. .sp
  972. This server uses the WSGI application object specified by the
  973. \fBWSGI_APPLICATION\fP setting.
  974. .sp
  975. DO NOT USE THIS SERVER IN A PRODUCTION SETTING. It has not gone through
  976. security audits or performance tests. (And that\(aqs how it\(aqs gonna stay. We\(aqre in
  977. the business of making Web frameworks, not Web servers, so improving this
  978. server to be able to handle a production environment is outside the scope of
  979. Django.)
  980. .sp
  981. The development server automatically reloads Python code for each request, as
  982. needed. You don\(aqt need to restart the server for code changes to take effect.
  983. However, some actions like adding files don\(aqt trigger a restart, so you\(aqll
  984. have to restart the server in these cases.
  985. .sp
  986. If you are using Linux and install \fI\%pyinotify\fP, kernel signals will be used to
  987. autoreload the server (rather than polling file modification timestamps each
  988. second). This offers better scaling to large projects, reduction in response
  989. time to code modification, more robust change detection, and battery usage
  990. reduction.
  991. .sp
  992. When you start the server, and each time you change Python code while the
  993. server is running, the server will check your entire Django project for errors (see
  994. the \fI\%check\fP command). If any errors are found, they will be printed
  995. to standard output, but it won\(aqt stop the server.
  996. .sp
  997. You can run as many servers as you want, as long as they\(aqre on separate ports.
  998. Just execute \fBdjango\-admin runserver\fP more than once.
  999. .sp
  1000. Note that the default IP address, \fB127.0.0.1\fP, is not accessible from other
  1001. machines on your network. To make your development server viewable to other
  1002. machines on the network, use its own IP address (e.g. \fB192.168.2.1\fP) or
  1003. \fB0.0.0.0\fP or \fB::\fP (with IPv6 enabled).
  1004. .sp
  1005. You can provide an IPv6 address surrounded by brackets
  1006. (e.g. \fB[200a::1]:8000\fP). This will automatically enable IPv6 support.
  1007. .sp
  1008. A hostname containing ASCII\-only characters can also be used.
  1009. .sp
  1010. If the \fBstaticfiles\fP contrib app is enabled
  1011. (default in new projects) the \fI\%runserver\fP command will be overridden
  1012. with its own \fIrunserver\fP command.
  1013. .sp
  1014. If \fI\%migrate\fP was not previously executed, the table that stores the
  1015. history of migrations is created at first run of \fBrunserver\fP\&.
  1016. .INDENT 0.0
  1017. .TP
  1018. .B \-\-noreload
  1019. .UNINDENT
  1020. .sp
  1021. Use the \fB\-\-noreload\fP option to disable the use of the auto\-reloader. This
  1022. means any Python code changes you make while the server is running will \fInot\fP
  1023. take effect if the particular Python modules have already been loaded into
  1024. memory.
  1025. .sp
  1026. Example usage:
  1027. .INDENT 0.0
  1028. .INDENT 3.5
  1029. .sp
  1030. .nf
  1031. .ft C
  1032. django\-admin runserver \-\-noreload
  1033. .ft P
  1034. .fi
  1035. .UNINDENT
  1036. .UNINDENT
  1037. .INDENT 0.0
  1038. .TP
  1039. .B \-\-nothreading
  1040. .UNINDENT
  1041. .sp
  1042. The development server is multithreaded by default. Use the \fB\-\-nothreading\fP
  1043. option to disable the use of threading in the development server.
  1044. .INDENT 0.0
  1045. .TP
  1046. .B \-\-ipv6, \-6
  1047. .UNINDENT
  1048. .sp
  1049. Use the \fB\-\-ipv6\fP (or shorter \fB\-6\fP) option to tell Django to use IPv6 for
  1050. the development server. This changes the default IP address from
  1051. \fB127.0.0.1\fP to \fB::1\fP\&.
  1052. .sp
  1053. Example usage:
  1054. .INDENT 0.0
  1055. .INDENT 3.5
  1056. .sp
  1057. .nf
  1058. .ft C
  1059. django\-admin runserver \-\-ipv6
  1060. .ft P
  1061. .fi
  1062. .UNINDENT
  1063. .UNINDENT
  1064. .SS Examples of using different ports and addresses
  1065. .sp
  1066. Port 8000 on IP address \fB127.0.0.1\fP:
  1067. .INDENT 0.0
  1068. .INDENT 3.5
  1069. .sp
  1070. .nf
  1071. .ft C
  1072. django\-admin runserver
  1073. .ft P
  1074. .fi
  1075. .UNINDENT
  1076. .UNINDENT
  1077. .sp
  1078. Port 8000 on IP address \fB1.2.3.4\fP:
  1079. .INDENT 0.0
  1080. .INDENT 3.5
  1081. .sp
  1082. .nf
  1083. .ft C
  1084. django\-admin runserver 1.2.3.4:8000
  1085. .ft P
  1086. .fi
  1087. .UNINDENT
  1088. .UNINDENT
  1089. .sp
  1090. Port 7000 on IP address \fB127.0.0.1\fP:
  1091. .INDENT 0.0
  1092. .INDENT 3.5
  1093. .sp
  1094. .nf
  1095. .ft C
  1096. django\-admin runserver 7000
  1097. .ft P
  1098. .fi
  1099. .UNINDENT
  1100. .UNINDENT
  1101. .sp
  1102. Port 7000 on IP address \fB1.2.3.4\fP:
  1103. .INDENT 0.0
  1104. .INDENT 3.5
  1105. .sp
  1106. .nf
  1107. .ft C
  1108. django\-admin runserver 1.2.3.4:7000
  1109. .ft P
  1110. .fi
  1111. .UNINDENT
  1112. .UNINDENT
  1113. .sp
  1114. Port 8000 on IPv6 address \fB::1\fP:
  1115. .INDENT 0.0
  1116. .INDENT 3.5
  1117. .sp
  1118. .nf
  1119. .ft C
  1120. django\-admin runserver \-6
  1121. .ft P
  1122. .fi
  1123. .UNINDENT
  1124. .UNINDENT
  1125. .sp
  1126. Port 7000 on IPv6 address \fB::1\fP:
  1127. .INDENT 0.0
  1128. .INDENT 3.5
  1129. .sp
  1130. .nf
  1131. .ft C
  1132. django\-admin runserver \-6 7000
  1133. .ft P
  1134. .fi
  1135. .UNINDENT
  1136. .UNINDENT
  1137. .sp
  1138. Port 7000 on IPv6 address \fB2001:0db8:1234:5678::9\fP:
  1139. .INDENT 0.0
  1140. .INDENT 3.5
  1141. .sp
  1142. .nf
  1143. .ft C
  1144. django\-admin runserver [2001:0db8:1234:5678::9]:7000
  1145. .ft P
  1146. .fi
  1147. .UNINDENT
  1148. .UNINDENT
  1149. .sp
  1150. Port 8000 on IPv4 address of host \fBlocalhost\fP:
  1151. .INDENT 0.0
  1152. .INDENT 3.5
  1153. .sp
  1154. .nf
  1155. .ft C
  1156. django\-admin runserver localhost:8000
  1157. .ft P
  1158. .fi
  1159. .UNINDENT
  1160. .UNINDENT
  1161. .sp
  1162. Port 8000 on IPv6 address of host \fBlocalhost\fP:
  1163. .INDENT 0.0
  1164. .INDENT 3.5
  1165. .sp
  1166. .nf
  1167. .ft C
  1168. django\-admin runserver \-6 localhost:8000
  1169. .ft P
  1170. .fi
  1171. .UNINDENT
  1172. .UNINDENT
  1173. .SS Serving static files with the development server
  1174. .sp
  1175. By default, the development server doesn\(aqt serve any static files for your site
  1176. (such as CSS files, images, things under \fBMEDIA_URL\fP and so forth). If
  1177. you want to configure Django to serve static media, read
  1178. \fB/howto/static\-files/index\fP\&.
  1179. .SS shell
  1180. .INDENT 0.0
  1181. .TP
  1182. .B django\-admin shell
  1183. .UNINDENT
  1184. .sp
  1185. Starts the Python interactive interpreter.
  1186. .sp
  1187. Django will use \fI\%IPython\fP or \fI\%bpython\fP if either is installed. If you have a
  1188. rich shell installed but want to force use of the "plain" Python interpreter,
  1189. use the \fB\-\-plain\fP option, like so:
  1190. .INDENT 0.0
  1191. .INDENT 3.5
  1192. .sp
  1193. .nf
  1194. .ft C
  1195. django\-admin shell \-\-plain
  1196. .ft P
  1197. .fi
  1198. .UNINDENT
  1199. .UNINDENT
  1200. .sp
  1201. If you would like to specify either IPython or bpython as your interpreter if
  1202. you have both installed you can specify an alternative interpreter interface
  1203. with the \fB\-i\fP or \fB\-\-interface\fP options like so:
  1204. .sp
  1205. IPython:
  1206. .INDENT 0.0
  1207. .INDENT 3.5
  1208. .sp
  1209. .nf
  1210. .ft C
  1211. django\-admin shell \-i ipython
  1212. django\-admin shell \-\-interface ipython
  1213. .ft P
  1214. .fi
  1215. .UNINDENT
  1216. .UNINDENT
  1217. .sp
  1218. bpython:
  1219. .INDENT 0.0
  1220. .INDENT 3.5
  1221. .sp
  1222. .nf
  1223. .ft C
  1224. django\-admin shell \-i bpython
  1225. django\-admin shell \-\-interface bpython
  1226. .ft P
  1227. .fi
  1228. .UNINDENT
  1229. .UNINDENT
  1230. .sp
  1231. When the "plain" Python interactive interpreter starts (be it because
  1232. \fB\-\-plain\fP was specified or because no other interactive interface is
  1233. available) it reads the script pointed to by the \fI\%PYTHONSTARTUP\fP
  1234. environment variable and the \fB~/.pythonrc.py\fP script. If you don\(aqt wish this
  1235. behavior you can use the \fB\-\-no\-startup\fP option. e.g.:
  1236. .INDENT 0.0
  1237. .INDENT 3.5
  1238. .sp
  1239. .nf
  1240. .ft C
  1241. django\-admin shell \-\-plain \-\-no\-startup
  1242. .ft P
  1243. .fi
  1244. .UNINDENT
  1245. .UNINDENT
  1246. .SS showmigrations [<app_label> [<app_label>]]
  1247. .INDENT 0.0
  1248. .TP
  1249. .B django\-admin showmigrations
  1250. .UNINDENT
  1251. .sp
  1252. .sp
  1253. Shows all migrations in a project.
  1254. .INDENT 0.0
  1255. .TP
  1256. .B \-\-list, \-l
  1257. .UNINDENT
  1258. .sp
  1259. The \fB\-\-list\fP option lists all of the apps Django knows about, the
  1260. migrations available for each app, and whether or not each migrations is
  1261. applied (marked by an \fB[X]\fP next to the migration name).
  1262. .sp
  1263. Apps without migrations are also listed, but have \fB(no migrations)\fP printed
  1264. under them.
  1265. .INDENT 0.0
  1266. .TP
  1267. .B \-\-plan, \-p
  1268. .UNINDENT
  1269. .sp
  1270. The \fB\-\-plan\fP option shows the migration plan Django will follow to apply
  1271. migrations. Any supplied app labels are ignored because the plan might go
  1272. beyond those apps. Same as \fB\-\-list\fP, applied migrations are marked by an
  1273. \fB[X]\fP\&. For a verbosity of 2 and above, all dependencies of a migration will
  1274. also be shown.
  1275. .SS sqlflush
  1276. .INDENT 0.0
  1277. .TP
  1278. .B django\-admin sqlflush
  1279. .UNINDENT
  1280. .sp
  1281. Prints the SQL statements that would be executed for the \fI\%flush\fP
  1282. command.
  1283. .sp
  1284. The \fI\%\-\-database\fP option can be used to specify the database for
  1285. which to print the SQL.
  1286. .SS sqlmigrate <app_label> <migrationname>
  1287. .INDENT 0.0
  1288. .TP
  1289. .B django\-admin sqlmigrate
  1290. .UNINDENT
  1291. .sp
  1292. Prints the SQL for the named migration. This requires an active database
  1293. connection, which it will use to resolve constraint names; this means you must
  1294. generate the SQL against a copy of the database you wish to later apply it on.
  1295. .sp
  1296. Note that \fBsqlmigrate\fP doesn\(aqt colorize its output.
  1297. .sp
  1298. The \fI\%\-\-database\fP option can be used to specify the database for
  1299. which to generate the SQL.
  1300. .INDENT 0.0
  1301. .TP
  1302. .B \-\-backwards
  1303. .UNINDENT
  1304. .sp
  1305. By default, the SQL created is for running the migration in the forwards
  1306. direction. Pass \fB\-\-backwards\fP to generate the SQL for
  1307. unapplying the migration instead.
  1308. .SS sqlsequencereset <app_label app_label ...>
  1309. .INDENT 0.0
  1310. .TP
  1311. .B django\-admin sqlsequencereset
  1312. .UNINDENT
  1313. .sp
  1314. Prints the SQL statements for resetting sequences for the given app name(s).
  1315. .sp
  1316. Sequences are indexes used by some database engines to track the next available
  1317. number for automatically incremented fields.
  1318. .sp
  1319. Use this command to generate SQL which will fix cases where a sequence is out
  1320. of sync with its automatically incremented field data.
  1321. .sp
  1322. The \fI\%\-\-database\fP option can be used to specify the database for
  1323. which to print the SQL.
  1324. .SS squashmigrations <app_label> <migration_name>
  1325. .INDENT 0.0
  1326. .TP
  1327. .B django\-admin squashmigrations
  1328. .UNINDENT
  1329. .sp
  1330. Squashes the migrations for \fBapp_label\fP up to and including \fBmigration_name\fP
  1331. down into fewer migrations, if possible. The resulting squashed migrations
  1332. can live alongside the unsquashed ones safely. For more information,
  1333. please read \fImigration\-squashing\fP\&.
  1334. .INDENT 0.0
  1335. .TP
  1336. .B \-\-no\-optimize
  1337. .UNINDENT
  1338. .sp
  1339. By default, Django will try to optimize the operations in your migrations
  1340. to reduce the size of the resulting file. Pass \fB\-\-no\-optimize\fP if this
  1341. process is failing for you or creating incorrect migrations, though please
  1342. also file a Django bug report about the behavior, as optimization is meant
  1343. to be safe.
  1344. .SS startapp <app_label> [destination]
  1345. .INDENT 0.0
  1346. .TP
  1347. .B django\-admin startapp
  1348. .UNINDENT
  1349. .sp
  1350. Creates a Django app directory structure for the given app name in the current
  1351. directory or the given destination.
  1352. .sp
  1353. By default the directory created contains a \fBmodels.py\fP file and other app
  1354. template files. (See the \fI\%source\fP for more details.) If only the app
  1355. name is given, the app directory will be created in the current working
  1356. directory.
  1357. .sp
  1358. If the optional destination is provided, Django will use that existing
  1359. directory rather than creating a new one. You can use \(aq.\(aq to denote the current
  1360. working directory.
  1361. .sp
  1362. For example:
  1363. .INDENT 0.0
  1364. .INDENT 3.5
  1365. .sp
  1366. .nf
  1367. .ft C
  1368. django\-admin startapp myapp /Users/jezdez/Code/myapp
  1369. .ft P
  1370. .fi
  1371. .UNINDENT
  1372. .UNINDENT
  1373. .INDENT 0.0
  1374. .TP
  1375. .B \-\-template
  1376. .UNINDENT
  1377. .sp
  1378. With the \fB\-\-template\fP option, you can use a custom app template by providing
  1379. either the path to a directory with the app template file, or a path to a
  1380. compressed file (\fB\&.tar.gz\fP, \fB\&.tar.bz2\fP, \fB\&.tgz\fP, \fB\&.tbz\fP, \fB\&.zip\fP)
  1381. containing the app template files.
  1382. .sp
  1383. For example, this would look for an app template in the given directory when
  1384. creating the \fBmyapp\fP app:
  1385. .INDENT 0.0
  1386. .INDENT 3.5
  1387. .sp
  1388. .nf
  1389. .ft C
  1390. django\-admin startapp \-\-template=/Users/jezdez/Code/my_app_template myapp
  1391. .ft P
  1392. .fi
  1393. .UNINDENT
  1394. .UNINDENT
  1395. .sp
  1396. Django will also accept URLs (\fBhttp\fP, \fBhttps\fP, \fBftp\fP) to compressed
  1397. archives with the app template files, downloading and extracting them on the
  1398. fly.
  1399. .sp
  1400. For example, taking advantage of Github\(aqs feature to expose repositories as
  1401. zip files, you can use a URL like:
  1402. .INDENT 0.0
  1403. .INDENT 3.5
  1404. .sp
  1405. .nf
  1406. .ft C
  1407. django\-admin startapp \-\-template=https://github.com/githubuser/django\-app\-template/archive/master.zip myapp
  1408. .ft P
  1409. .fi
  1410. .UNINDENT
  1411. .UNINDENT
  1412. .sp
  1413. When Django copies the app template files, it also renders certain files
  1414. through the template engine: the files whose extensions match the
  1415. \fB\-\-extension\fP option (\fBpy\fP by default) and the files whose names are passed
  1416. with the \fB\-\-name\fP option. The \fBtemplate context\fP used is:
  1417. .INDENT 0.0
  1418. .IP \(bu 2
  1419. Any option passed to the \fBstartapp\fP command (among the command\(aqs supported
  1420. options)
  1421. .IP \(bu 2
  1422. \fBapp_name\fP \-\- the app name as passed to the command
  1423. .IP \(bu 2
  1424. \fBapp_directory\fP \-\- the full path of the newly created app
  1425. .IP \(bu 2
  1426. \fBdocs_version\fP \-\- the version of the documentation: \fB\(aqdev\(aq\fP or \fB\(aq1.x\(aq\fP
  1427. .UNINDENT
  1428. .sp
  1429. \fBWARNING:\fP
  1430. .INDENT 0.0
  1431. .INDENT 3.5
  1432. When the app template files are rendered with the Django template
  1433. engine (by default all \fB*.py\fP files), Django will also replace all
  1434. stray template variables contained. For example, if one of the Python files
  1435. contains a docstring explaining a particular feature related
  1436. to template rendering, it might result in an incorrect example.
  1437. .sp
  1438. To work around this problem, you can use the \fBtemplatetag\fP
  1439. templatetag to "escape" the various parts of the template syntax.
  1440. .UNINDENT
  1441. .UNINDENT
  1442. .SS startproject <projectname> [destination]
  1443. .INDENT 0.0
  1444. .TP
  1445. .B django\-admin startproject
  1446. .UNINDENT
  1447. .sp
  1448. Creates a Django project directory structure for the given project name in
  1449. the current directory or the given destination.
  1450. .sp
  1451. By default, the new directory contains \fBmanage.py\fP and a project package
  1452. (containing a \fBsettings.py\fP and other files). See the \fI\%template source\fP for
  1453. details.
  1454. .sp
  1455. If only the project name is given, both the project directory and project
  1456. package will be named \fB<projectname>\fP and the project directory
  1457. will be created in the current working directory.
  1458. .sp
  1459. If the optional destination is provided, Django will use that existing
  1460. directory as the project directory, and create \fBmanage.py\fP and the project
  1461. package within it. Use \(aq.\(aq to denote the current working directory.
  1462. .sp
  1463. For example:
  1464. .INDENT 0.0
  1465. .INDENT 3.5
  1466. .sp
  1467. .nf
  1468. .ft C
  1469. django\-admin startproject myproject /Users/jezdez/Code/myproject_repo
  1470. .ft P
  1471. .fi
  1472. .UNINDENT
  1473. .UNINDENT
  1474. .sp
  1475. As with the \fI\%startapp\fP command, the \fB\-\-template\fP option lets you
  1476. specify a directory, file path or URL of a custom project template. See the
  1477. \fI\%startapp\fP documentation for details of supported project template
  1478. formats.
  1479. .sp
  1480. For example, this would look for a project template in the given directory
  1481. when creating the \fBmyproject\fP project:
  1482. .INDENT 0.0
  1483. .INDENT 3.5
  1484. .sp
  1485. .nf
  1486. .ft C
  1487. django\-admin startproject \-\-template=/Users/jezdez/Code/my_project_template myproject
  1488. .ft P
  1489. .fi
  1490. .UNINDENT
  1491. .UNINDENT
  1492. .sp
  1493. Django will also accept URLs (\fBhttp\fP, \fBhttps\fP, \fBftp\fP) to compressed
  1494. archives with the project template files, downloading and extracting them on the
  1495. fly.
  1496. .sp
  1497. For example, taking advantage of Github\(aqs feature to expose repositories as
  1498. zip files, you can use a URL like:
  1499. .INDENT 0.0
  1500. .INDENT 3.5
  1501. .sp
  1502. .nf
  1503. .ft C
  1504. django\-admin startproject \-\-template=https://github.com/githubuser/django\-project\-template/archive/master.zip myproject
  1505. .ft P
  1506. .fi
  1507. .UNINDENT
  1508. .UNINDENT
  1509. .sp
  1510. When Django copies the project template files, it also renders certain files
  1511. through the template engine: the files whose extensions match the
  1512. \fB\-\-extension\fP option (\fBpy\fP by default) and the files whose names are passed
  1513. with the \fB\-\-name\fP option. The \fBtemplate context\fP used is:
  1514. .INDENT 0.0
  1515. .IP \(bu 2
  1516. Any option passed to the \fBstartproject\fP command (among the command\(aqs
  1517. supported options)
  1518. .IP \(bu 2
  1519. \fBproject_name\fP \-\- the project name as passed to the command
  1520. .IP \(bu 2
  1521. \fBproject_directory\fP \-\- the full path of the newly created project
  1522. .IP \(bu 2
  1523. \fBsecret_key\fP \-\- a random key for the \fBSECRET_KEY\fP setting
  1524. .IP \(bu 2
  1525. \fBdocs_version\fP \-\- the version of the documentation: \fB\(aqdev\(aq\fP or \fB\(aq1.x\(aq\fP
  1526. .UNINDENT
  1527. .sp
  1528. Please also see the \fI\%rendering warning\fP as mentioned
  1529. for \fI\%startapp\fP\&.
  1530. .SS test <app or test identifier>
  1531. .INDENT 0.0
  1532. .TP
  1533. .B django\-admin test
  1534. .UNINDENT
  1535. .sp
  1536. Runs tests for all installed models. See \fB/topics/testing/index\fP for more
  1537. information.
  1538. .INDENT 0.0
  1539. .TP
  1540. .B \-\-failfast
  1541. .UNINDENT
  1542. .sp
  1543. The \fB\-\-failfast\fP option can be used to stop running tests and report the
  1544. failure immediately after a test fails.
  1545. .INDENT 0.0
  1546. .TP
  1547. .B \-\-testrunner
  1548. .UNINDENT
  1549. .sp
  1550. The \fB\-\-testrunner\fP option can be used to control the test runner class that
  1551. is used to execute tests. If this value is provided, it overrides the value
  1552. provided by the \fBTEST_RUNNER\fP setting.
  1553. .INDENT 0.0
  1554. .TP
  1555. .B \-\-liveserver
  1556. .UNINDENT
  1557. .sp
  1558. The \fB\-\-liveserver\fP option can be used to override the default address where
  1559. the live server (used with \fBLiveServerTestCase\fP) is
  1560. expected to run from. The default value is \fBlocalhost:8081\fP\&.
  1561. .INDENT 0.0
  1562. .TP
  1563. .B \-\-keepdb
  1564. .UNINDENT
  1565. .sp
  1566. .sp
  1567. The \fB\-\-keepdb\fP option can be used to preserve the test database between test
  1568. runs. This has the advantage of skipping both the create and destroy actions
  1569. which greatly decreases the time to run tests, especially those in a large
  1570. test suite. If the test database does not exist, it will be created on the first
  1571. run and then preserved for each subsequent run. Any unapplied migrations will also
  1572. be applied to the test database before running the test suite.
  1573. .INDENT 0.0
  1574. .TP
  1575. .B \-\-reverse
  1576. .UNINDENT
  1577. .sp
  1578. .sp
  1579. The \fB\-\-reverse\fP option can be used to sort test cases in the opposite order.
  1580. This may help in debugging tests that aren\(aqt properly isolated and have side
  1581. effects. \fIGrouping by test class\fP is preserved when using
  1582. this option.
  1583. .INDENT 0.0
  1584. .TP
  1585. .B \-\-debug\-sql
  1586. .UNINDENT
  1587. .sp
  1588. .sp
  1589. The \fB\-\-debug\-sql\fP option can be used to enable \fISQL logging\fP for failing tests. If \fI\%\-\-verbosity\fP is \fB2\fP,
  1590. then queries in passing tests are also output.
  1591. .SS testserver <fixture fixture ...>
  1592. .INDENT 0.0
  1593. .TP
  1594. .B django\-admin testserver
  1595. .UNINDENT
  1596. .sp
  1597. Runs a Django development server (as in \fI\%runserver\fP) using data from
  1598. the given fixture(s).
  1599. .sp
  1600. For example, this command:
  1601. .INDENT 0.0
  1602. .INDENT 3.5
  1603. .sp
  1604. .nf
  1605. .ft C
  1606. django\-admin testserver mydata.json
  1607. .ft P
  1608. .fi
  1609. .UNINDENT
  1610. .UNINDENT
  1611. .sp
  1612. \&...would perform the following steps:
  1613. .INDENT 0.0
  1614. .IP 1. 3
  1615. Create a test database, as described in \fIthe\-test\-database\fP\&.
  1616. .IP 2. 3
  1617. Populate the test database with fixture data from the given fixtures.
  1618. (For more on fixtures, see the documentation for \fI\%loaddata\fP above.)
  1619. .IP 3. 3
  1620. Runs the Django development server (as in \fI\%runserver\fP), pointed at
  1621. this newly created test database instead of your production database.
  1622. .UNINDENT
  1623. .sp
  1624. This is useful in a number of ways:
  1625. .INDENT 0.0
  1626. .IP \(bu 2
  1627. When you\(aqre writing \fBunit tests\fP of how your views
  1628. act with certain fixture data, you can use \fBtestserver\fP to interact with
  1629. the views in a Web browser, manually.
  1630. .IP \(bu 2
  1631. Let\(aqs say you\(aqre developing your Django application and have a "pristine"
  1632. copy of a database that you\(aqd like to interact with. You can dump your
  1633. database to a fixture (using the \fI\%dumpdata\fP command, explained
  1634. above), then use \fBtestserver\fP to run your Web application with that data.
  1635. With this arrangement, you have the flexibility of messing up your data
  1636. in any way, knowing that whatever data changes you\(aqre making are only
  1637. being made to a test database.
  1638. .UNINDENT
  1639. .sp
  1640. Note that this server does \fInot\fP automatically detect changes to your Python
  1641. source code (as \fI\%runserver\fP does). It does, however, detect changes to
  1642. templates.
  1643. .INDENT 0.0
  1644. .TP
  1645. .B \-\-addrport [port number or ipaddr:port]
  1646. .UNINDENT
  1647. .sp
  1648. Use \fB\-\-addrport\fP to specify a different port, or IP address and port, from
  1649. the default of \fB127.0.0.1:8000\fP\&. This value follows exactly the same format and
  1650. serves exactly the same function as the argument to the \fI\%runserver\fP
  1651. command.
  1652. .sp
  1653. Examples:
  1654. .sp
  1655. To run the test server on port 7000 with \fBfixture1\fP and \fBfixture2\fP:
  1656. .INDENT 0.0
  1657. .INDENT 3.5
  1658. .sp
  1659. .nf
  1660. .ft C
  1661. django\-admin testserver \-\-addrport 7000 fixture1 fixture2
  1662. django\-admin testserver fixture1 fixture2 \-\-addrport 7000
  1663. .ft P
  1664. .fi
  1665. .UNINDENT
  1666. .UNINDENT
  1667. .sp
  1668. (The above statements are equivalent. We include both of them to demonstrate
  1669. that it doesn\(aqt matter whether the options come before or after the fixture
  1670. arguments.)
  1671. .sp
  1672. To run on 1.2.3.4:7000 with a \fBtest\fP fixture:
  1673. .INDENT 0.0
  1674. .INDENT 3.5
  1675. .sp
  1676. .nf
  1677. .ft C
  1678. django\-admin testserver \-\-addrport 1.2.3.4:7000 test
  1679. .ft P
  1680. .fi
  1681. .UNINDENT
  1682. .UNINDENT
  1683. .sp
  1684. The \fI\%\-\-noinput\fP option may be provided to suppress all user
  1685. prompts.
  1686. .SH COMMANDS PROVIDED BY APPLICATIONS
  1687. .sp
  1688. Some commands are only available when the \fBdjango.contrib\fP application that
  1689. \fBimplements\fP them has been
  1690. \fBenabled\fP\&. This section describes them grouped by
  1691. their application.
  1692. .SS \fBdjango.contrib.auth\fP
  1693. .SS changepassword
  1694. .INDENT 0.0
  1695. .TP
  1696. .B django\-admin changepassword
  1697. .UNINDENT
  1698. .sp
  1699. This command is only available if Django\(aqs \fBauthentication system\fP (\fBdjango.contrib.auth\fP) is installed.
  1700. .sp
  1701. Allows changing a user\(aqs password. It prompts you to enter twice the password of
  1702. the user given as parameter. If they both match, the new password will be
  1703. changed immediately. If you do not supply a user, the command will attempt to
  1704. change the password whose username matches the current user.
  1705. .sp
  1706. Use the \fB\-\-database\fP option to specify the database to query for the user. If
  1707. it\(aqs not supplied, Django will use the \fBdefault\fP database.
  1708. .sp
  1709. Example usage:
  1710. .INDENT 0.0
  1711. .INDENT 3.5
  1712. .sp
  1713. .nf
  1714. .ft C
  1715. django\-admin changepassword ringo
  1716. .ft P
  1717. .fi
  1718. .UNINDENT
  1719. .UNINDENT
  1720. .SS createsuperuser
  1721. .INDENT 0.0
  1722. .TP
  1723. .B django\-admin createsuperuser
  1724. .UNINDENT
  1725. .sp
  1726. This command is only available if Django\(aqs \fBauthentication system\fP (\fBdjango.contrib.auth\fP) is installed.
  1727. .sp
  1728. Creates a superuser account (a user who has all permissions). This is
  1729. useful if you need to create an initial superuser account or if you need to
  1730. programmatically generate superuser accounts for your site(s).
  1731. .sp
  1732. When run interactively, this command will prompt for a password for
  1733. the new superuser account. When run non\-interactively, no password
  1734. will be set, and the superuser account will not be able to log in until
  1735. a password has been manually set for it.
  1736. .INDENT 0.0
  1737. .TP
  1738. .B \-\-username
  1739. .UNINDENT
  1740. .INDENT 0.0
  1741. .TP
  1742. .B \-\-email
  1743. .UNINDENT
  1744. .sp
  1745. The username and email address for the new account can be supplied by
  1746. using the \fB\-\-username\fP and \fB\-\-email\fP arguments on the command
  1747. line. If either of those is not supplied, \fBcreatesuperuser\fP will prompt for
  1748. it when running interactively.
  1749. .sp
  1750. Use the \fB\-\-database\fP option to specify the database into which the superuser
  1751. object will be saved.
  1752. .sp
  1753. .sp
  1754. You can subclass the management command and override \fBget_input_data()\fP if you
  1755. want to customize data input and validation. Consult the source code for
  1756. details on the existing implementation and the method\(aqs parameters. For example,
  1757. it could be useful if you have a \fBForeignKey\fP in
  1758. \fBREQUIRED_FIELDS\fP and want to
  1759. allow creating an instance instead of entering the primary key of an existing
  1760. instance.
  1761. .SS \fBdjango.contrib.gis\fP
  1762. .SS ogrinspect
  1763. .sp
  1764. This command is only available if \fBGeoDjango\fP
  1765. (\fBdjango.contrib.gis\fP) is installed.
  1766. .sp
  1767. Please refer to its \fBdescription\fP in the GeoDjango
  1768. documentation.
  1769. .SS \fBdjango.contrib.sessions\fP
  1770. .SS clearsessions
  1771. .INDENT 0.0
  1772. .TP
  1773. .B django\-admin clearsessions
  1774. .UNINDENT
  1775. .sp
  1776. Can be run as a cron job or directly to clean out expired sessions.
  1777. .SS \fBdjango.contrib.sitemaps\fP
  1778. .SS ping_google
  1779. .sp
  1780. This command is only available if the \fBSitemaps framework\fP (\fBdjango.contrib.sitemaps\fP) is installed.
  1781. .sp
  1782. Please refer to its \fBdescription\fP in the Sitemaps
  1783. documentation.
  1784. .SS \fBdjango.contrib.staticfiles\fP
  1785. .SS collectstatic
  1786. .sp
  1787. This command is only available if the \fBstatic files application\fP (\fBdjango.contrib.staticfiles\fP) is installed.
  1788. .sp
  1789. Please refer to its \fBdescription\fP in the
  1790. \fBstaticfiles\fP documentation.
  1791. .SS findstatic
  1792. .sp
  1793. This command is only available if the \fBstatic files application\fP (\fBdjango.contrib.staticfiles\fP) is installed.
  1794. .sp
  1795. Please refer to its \fBdescription\fP in the \fBstaticfiles\fP documentation.
  1796. .SH DEFAULT OPTIONS
  1797. .sp
  1798. Although some commands may allow their own custom options, every command
  1799. allows for the following options:
  1800. .INDENT 0.0
  1801. .TP
  1802. .B \-\-pythonpath
  1803. .UNINDENT
  1804. .sp
  1805. Example usage:
  1806. .INDENT 0.0
  1807. .INDENT 3.5
  1808. .sp
  1809. .nf
  1810. .ft C
  1811. django\-admin migrate \-\-pythonpath=\(aq/home/djangoprojects/myproject\(aq
  1812. .ft P
  1813. .fi
  1814. .UNINDENT
  1815. .UNINDENT
  1816. .sp
  1817. Adds the given filesystem path to the Python \fI\%import search path\fP\&. If this
  1818. isn\(aqt provided, \fBdjango\-admin\fP will use the \fBPYTHONPATH\fP environment
  1819. variable.
  1820. .sp
  1821. Note that this option is unnecessary in \fBmanage.py\fP, because it takes care of
  1822. setting the Python path for you.
  1823. .INDENT 0.0
  1824. .TP
  1825. .B \-\-settings
  1826. .UNINDENT
  1827. .sp
  1828. Example usage:
  1829. .INDENT 0.0
  1830. .INDENT 3.5
  1831. .sp
  1832. .nf
  1833. .ft C
  1834. django\-admin migrate \-\-settings=mysite.settings
  1835. .ft P
  1836. .fi
  1837. .UNINDENT
  1838. .UNINDENT
  1839. .sp
  1840. Explicitly specifies the settings module to use. The settings module should be
  1841. in Python package syntax, e.g. \fBmysite.settings\fP\&. If this isn\(aqt provided,
  1842. \fBdjango\-admin\fP will use the \fBDJANGO_SETTINGS_MODULE\fP environment
  1843. variable.
  1844. .sp
  1845. Note that this option is unnecessary in \fBmanage.py\fP, because it uses
  1846. \fBsettings.py\fP from the current project by default.
  1847. .INDENT 0.0
  1848. .TP
  1849. .B \-\-traceback
  1850. .UNINDENT
  1851. .sp
  1852. Example usage:
  1853. .INDENT 0.0
  1854. .INDENT 3.5
  1855. .sp
  1856. .nf
  1857. .ft C
  1858. django\-admin migrate \-\-traceback
  1859. .ft P
  1860. .fi
  1861. .UNINDENT
  1862. .UNINDENT
  1863. .sp
  1864. By default, \fBdjango\-admin\fP will show a simple error message whenever an
  1865. \fBCommandError\fP occurs, but a full stack trace
  1866. for any other exception. If you specify \fB\-\-traceback\fP, \fBdjango\-admin\fP
  1867. will also output a full stack trace when a \fBCommandError\fP is raised.
  1868. .INDENT 0.0
  1869. .TP
  1870. .B \-\-verbosity
  1871. .UNINDENT
  1872. .sp
  1873. Example usage:
  1874. .INDENT 0.0
  1875. .INDENT 3.5
  1876. .sp
  1877. .nf
  1878. .ft C
  1879. django\-admin migrate \-\-verbosity 2
  1880. .ft P
  1881. .fi
  1882. .UNINDENT
  1883. .UNINDENT
  1884. .sp
  1885. Use \fB\-\-verbosity\fP to specify the amount of notification and debug information
  1886. that \fBdjango\-admin\fP should print to the console.
  1887. .INDENT 0.0
  1888. .IP \(bu 2
  1889. \fB0\fP means no output.
  1890. .IP \(bu 2
  1891. \fB1\fP means normal output (default).
  1892. .IP \(bu 2
  1893. \fB2\fP means verbose output.
  1894. .IP \(bu 2
  1895. \fB3\fP means \fIvery\fP verbose output.
  1896. .UNINDENT
  1897. .INDENT 0.0
  1898. .TP
  1899. .B \-\-no\-color
  1900. .UNINDENT
  1901. .sp
  1902. Example usage:
  1903. .INDENT 0.0
  1904. .INDENT 3.5
  1905. .sp
  1906. .nf
  1907. .ft C
  1908. django\-admin sqlall \-\-no\-color
  1909. .ft P
  1910. .fi
  1911. .UNINDENT
  1912. .UNINDENT
  1913. .sp
  1914. By default, \fBdjango\-admin\fP will format the output to be colorized. For
  1915. example, errors will be printed to the console in red and SQL statements will
  1916. be syntax highlighted. To prevent this and have a plain text output, pass the
  1917. \fB\-\-no\-color\fP option when running your command.
  1918. .SH COMMON OPTIONS
  1919. .sp
  1920. The following options are not available on every command, but they are common
  1921. to a number of commands.
  1922. .INDENT 0.0
  1923. .TP
  1924. .B \-\-database
  1925. .UNINDENT
  1926. .sp
  1927. Used to specify the database on which a command will operate. If not
  1928. specified, this option will default to an alias of \fBdefault\fP\&.
  1929. .sp
  1930. For example, to dump data from the database with the alias \fBmaster\fP:
  1931. .INDENT 0.0
  1932. .INDENT 3.5
  1933. .sp
  1934. .nf
  1935. .ft C
  1936. django\-admin dumpdata \-\-database=master
  1937. .ft P
  1938. .fi
  1939. .UNINDENT
  1940. .UNINDENT
  1941. .INDENT 0.0
  1942. .TP
  1943. .B \-\-exclude
  1944. .UNINDENT
  1945. .sp
  1946. Exclude a specific application from the applications whose contents is
  1947. output. For example, to specifically exclude the \fBauth\fP application from
  1948. the output of dumpdata, you would call:
  1949. .INDENT 0.0
  1950. .INDENT 3.5
  1951. .sp
  1952. .nf
  1953. .ft C
  1954. django\-admin dumpdata \-\-exclude=auth
  1955. .ft P
  1956. .fi
  1957. .UNINDENT
  1958. .UNINDENT
  1959. .sp
  1960. If you want to exclude multiple applications, use multiple \fB\-\-exclude\fP
  1961. directives:
  1962. .INDENT 0.0
  1963. .INDENT 3.5
  1964. .sp
  1965. .nf
  1966. .ft C
  1967. django\-admin dumpdata \-\-exclude=auth \-\-exclude=contenttypes
  1968. .ft P
  1969. .fi
  1970. .UNINDENT
  1971. .UNINDENT
  1972. .INDENT 0.0
  1973. .TP
  1974. .B \-\-locale
  1975. .UNINDENT
  1976. .sp
  1977. Use the \fB\-\-locale\fP or \fB\-l\fP option to specify the locale to process.
  1978. If not provided all locales are processed.
  1979. .INDENT 0.0
  1980. .TP
  1981. .B \-\-noinput
  1982. .UNINDENT
  1983. .sp
  1984. Use the \fB\-\-noinput\fP option to suppress all user prompting, such as "Are
  1985. you sure?" confirmation messages. This is useful if \fBdjango\-admin\fP is
  1986. being executed as an unattended, automated script.
  1987. .SH EXTRA NICETIES
  1988. .SS Syntax coloring
  1989. .sp
  1990. The \fBdjango\-admin\fP / \fBmanage.py\fP commands will use pretty
  1991. color\-coded output if your terminal supports ANSI\-colored output. It
  1992. won\(aqt use the color codes if you\(aqre piping the command\(aqs output to
  1993. another program.
  1994. .sp
  1995. Under Windows, the native console doesn\(aqt support ANSI escape sequences so by
  1996. default there is no color output. But you can install the \fI\%ANSICON\fP
  1997. third\-party tool, the Django commands will detect its presence and will make
  1998. use of its services to color output just like on Unix\-based platforms.
  1999. .sp
  2000. The colors used for syntax highlighting can be customized. Django
  2001. ships with three color palettes:
  2002. .INDENT 0.0
  2003. .IP \(bu 2
  2004. \fBdark\fP, suited to terminals that show white text on a black
  2005. background. This is the default palette.
  2006. .IP \(bu 2
  2007. \fBlight\fP, suited to terminals that show black text on a white
  2008. background.
  2009. .IP \(bu 2
  2010. \fBnocolor\fP, which disables syntax highlighting.
  2011. .UNINDENT
  2012. .sp
  2013. You select a palette by setting a \fBDJANGO_COLORS\fP environment
  2014. variable to specify the palette you want to use. For example, to
  2015. specify the \fBlight\fP palette under a Unix or OS/X BASH shell, you
  2016. would run the following at a command prompt:
  2017. .INDENT 0.0
  2018. .INDENT 3.5
  2019. .sp
  2020. .nf
  2021. .ft C
  2022. export DJANGO_COLORS="light"
  2023. .ft P
  2024. .fi
  2025. .UNINDENT
  2026. .UNINDENT
  2027. .sp
  2028. You can also customize the colors that are used. Django specifies a
  2029. number of roles in which color is used:
  2030. .INDENT 0.0
  2031. .IP \(bu 2
  2032. \fBerror\fP \- A major error.
  2033. .IP \(bu 2
  2034. \fBnotice\fP \- A minor error.
  2035. .IP \(bu 2
  2036. \fBsql_field\fP \- The name of a model field in SQL.
  2037. .IP \(bu 2
  2038. \fBsql_coltype\fP \- The type of a model field in SQL.
  2039. .IP \(bu 2
  2040. \fBsql_keyword\fP \- An SQL keyword.
  2041. .IP \(bu 2
  2042. \fBsql_table\fP \- The name of a model in SQL.
  2043. .IP \(bu 2
  2044. \fBhttp_info\fP \- A 1XX HTTP Informational server response.
  2045. .IP \(bu 2
  2046. \fBhttp_success\fP \- A 2XX HTTP Success server response.
  2047. .IP \(bu 2
  2048. \fBhttp_not_modified\fP \- A 304 HTTP Not Modified server response.
  2049. .IP \(bu 2
  2050. \fBhttp_redirect\fP \- A 3XX HTTP Redirect server response other than 304.
  2051. .IP \(bu 2
  2052. \fBhttp_not_found\fP \- A 404 HTTP Not Found server response.
  2053. .IP \(bu 2
  2054. \fBhttp_bad_request\fP \- A 4XX HTTP Bad Request server response other than 404.
  2055. .IP \(bu 2
  2056. \fBhttp_server_error\fP \- A 5XX HTTP Server Error response.
  2057. .UNINDENT
  2058. .sp
  2059. Each of these roles can be assigned a specific foreground and
  2060. background color, from the following list:
  2061. .INDENT 0.0
  2062. .IP \(bu 2
  2063. \fBblack\fP
  2064. .IP \(bu 2
  2065. \fBred\fP
  2066. .IP \(bu 2
  2067. \fBgreen\fP
  2068. .IP \(bu 2
  2069. \fByellow\fP
  2070. .IP \(bu 2
  2071. \fBblue\fP
  2072. .IP \(bu 2
  2073. \fBmagenta\fP
  2074. .IP \(bu 2
  2075. \fBcyan\fP
  2076. .IP \(bu 2
  2077. \fBwhite\fP
  2078. .UNINDENT
  2079. .sp
  2080. Each of these colors can then be modified by using the following
  2081. display options:
  2082. .INDENT 0.0
  2083. .IP \(bu 2
  2084. \fBbold\fP
  2085. .IP \(bu 2
  2086. \fBunderscore\fP
  2087. .IP \(bu 2
  2088. \fBblink\fP
  2089. .IP \(bu 2
  2090. \fBreverse\fP
  2091. .IP \(bu 2
  2092. \fBconceal\fP
  2093. .UNINDENT
  2094. .sp
  2095. A color specification follows one of the following patterns:
  2096. .INDENT 0.0
  2097. .IP \(bu 2
  2098. \fBrole=fg\fP
  2099. .IP \(bu 2
  2100. \fBrole=fg/bg\fP
  2101. .IP \(bu 2
  2102. \fBrole=fg,option,option\fP
  2103. .IP \(bu 2
  2104. \fBrole=fg/bg,option,option\fP
  2105. .UNINDENT
  2106. .sp
  2107. where \fBrole\fP is the name of a valid color role, \fBfg\fP is the
  2108. foreground color, \fBbg\fP is the background color and each \fBoption\fP
  2109. is one of the color modifying options. Multiple color specifications
  2110. are then separated by semicolon. For example:
  2111. .INDENT 0.0
  2112. .INDENT 3.5
  2113. .sp
  2114. .nf
  2115. .ft C
  2116. export DJANGO_COLORS="error=yellow/blue,blink;notice=magenta"
  2117. .ft P
  2118. .fi
  2119. .UNINDENT
  2120. .UNINDENT
  2121. .sp
  2122. would specify that errors be displayed using blinking yellow on blue,
  2123. and notices displayed using magenta. All other color roles would be
  2124. left uncolored.
  2125. .sp
  2126. Colors can also be specified by extending a base palette. If you put
  2127. a palette name in a color specification, all the colors implied by that
  2128. palette will be loaded. So:
  2129. .INDENT 0.0
  2130. .INDENT 3.5
  2131. .sp
  2132. .nf
  2133. .ft C
  2134. export DJANGO_COLORS="light;error=yellow/blue,blink;notice=magenta"
  2135. .ft P
  2136. .fi
  2137. .UNINDENT
  2138. .UNINDENT
  2139. .sp
  2140. would specify the use of all the colors in the light color palette,
  2141. \fIexcept\fP for the colors for errors and notices which would be
  2142. overridden as specified.
  2143. .SS Bash completion
  2144. .sp
  2145. If you use the Bash shell, consider installing the Django bash completion
  2146. script, which lives in \fBextras/django_bash_completion\fP in the Django
  2147. distribution. It enables tab\-completion of \fBdjango\-admin\fP and
  2148. \fBmanage.py\fP commands, so you can, for instance...
  2149. .INDENT 0.0
  2150. .IP \(bu 2
  2151. Type \fBdjango\-admin\fP\&.
  2152. .IP \(bu 2
  2153. Press [TAB] to see all available options.
  2154. .IP \(bu 2
  2155. Type \fBsql\fP, then [TAB], to see all available options whose names start
  2156. with \fBsql\fP\&.
  2157. .UNINDENT
  2158. .sp
  2159. See \fB/howto/custom\-management\-commands\fP for how to add customized actions.
  2160. .INDENT 0.0
  2161. .TP
  2162. .B django.core.management.call_command(name, *args, **options)
  2163. .UNINDENT
  2164. .sp
  2165. To call a management command from code use \fBcall_command\fP\&.
  2166. .INDENT 0.0
  2167. .TP
  2168. .B \fBname\fP
  2169. the name of the command to call.
  2170. .TP
  2171. .B \fB*args\fP
  2172. a list of arguments accepted by the command.
  2173. .TP
  2174. .B \fB**options\fP
  2175. named options accepted on the command\-line.
  2176. .UNINDENT
  2177. .sp
  2178. Examples:
  2179. .INDENT 0.0
  2180. .INDENT 3.5
  2181. .sp
  2182. .nf
  2183. .ft C
  2184. from django.core import management
  2185. management.call_command(\(aqflush\(aq, verbosity=0, interactive=False)
  2186. management.call_command(\(aqloaddata\(aq, \(aqtest_data\(aq, verbosity=0)
  2187. .ft P
  2188. .fi
  2189. .UNINDENT
  2190. .UNINDENT
  2191. .sp
  2192. Note that command options that take no arguments are passed as keywords
  2193. with \fBTrue\fP or \fBFalse\fP, as you can see with the \fBinteractive\fP option above.
  2194. .sp
  2195. Named arguments can be passed by using either one of the following syntaxes:
  2196. .INDENT 0.0
  2197. .INDENT 3.5
  2198. .sp
  2199. .nf
  2200. .ft C
  2201. # Similar to the command line
  2202. management.call_command(\(aqdumpdata\(aq, \(aq\-\-natural\-foreign\(aq)
  2203. # Named argument similar to the command line minus the initial dashes and
  2204. # with internal dashes replaced by underscores
  2205. management.call_command(\(aqdumpdata\(aq, natural_foreign=True)
  2206. # \(gause_natural_foreign_keys\(ga is the option destination variable
  2207. management.call_command(\(aqdumpdata\(aq, use_natural_foreign_keys=True)
  2208. .ft P
  2209. .fi
  2210. .UNINDENT
  2211. .UNINDENT
  2212. .sp
  2213. The first syntax is now supported thanks to management commands using the
  2214. \fI\%argparse\fP module. For the second syntax, Django previously passed
  2215. the option name as\-is to the command, now it is always using the \fBdest\fP
  2216. variable name (which may or may not be the same as the option name).
  2217. .sp
  2218. Command options which take multiple options are passed a list:
  2219. .INDENT 0.0
  2220. .INDENT 3.5
  2221. .sp
  2222. .nf
  2223. .ft C
  2224. management.call_command(\(aqdumpdata\(aq, exclude=[\(aqcontenttypes\(aq, \(aqauth\(aq])
  2225. .ft P
  2226. .fi
  2227. .UNINDENT
  2228. .UNINDENT
  2229. .SH OUTPUT REDIRECTION
  2230. .sp
  2231. Note that you can redirect standard output and error streams as all commands
  2232. support the \fBstdout\fP and \fBstderr\fP options. For example, you could write:
  2233. .INDENT 0.0
  2234. .INDENT 3.5
  2235. .sp
  2236. .nf
  2237. .ft C
  2238. with open(\(aq/tmp/command_output\(aq) as f:
  2239. management.call_command(\(aqdumpdata\(aq, stdout=f)
  2240. .ft P
  2241. .fi
  2242. .UNINDENT
  2243. .UNINDENT
  2244. .SH AUTHOR
  2245. Django Software Foundation
  2246. .SH COPYRIGHT
  2247. Django Software Foundation and contributors
  2248. .\" Generated by docutils manpage writer.
  2249. .