django-admin.1 80 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922
  1. .\" Man page generated from reStructuredText.
  2. .
  3. .TH "DJANGO-ADMIN" "1" "September 20, 2021" "4.0" "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. It
  38. does the same thing as \fBdjango\-admin\fP but also sets the
  39. \fBDJANGO_SETTINGS_MODULE\fP environment variable so that it points to your
  40. project\(aqs \fBsettings.py\fP file.
  41. .sp
  42. The \fBdjango\-admin\fP script should be on your system path if you installed
  43. Django via \fBpip\fP\&. If it\(aqs not in your path, ensure you have your virtual
  44. environment activated.
  45. .sp
  46. Generally, when working on a single Django project, it\(aqs easier to use
  47. \fBmanage.py\fP than \fBdjango\-admin\fP\&. If you need to switch between multiple
  48. Django settings files, use \fBdjango\-admin\fP with
  49. \fBDJANGO_SETTINGS_MODULE\fP or the \fI\%\-\-settings\fP command line
  50. option.
  51. .sp
  52. The command\-line examples throughout this document use \fBdjango\-admin\fP to
  53. be consistent, but any example can use \fBmanage.py\fP or \fBpython \-m django\fP
  54. just as well.
  55. .SH USAGE
  56. .INDENT 0.0
  57. .INDENT 3.5
  58. .sp
  59. .nf
  60. .ft C
  61. $ django\-admin <command> [options]
  62. $ manage.py <command> [options]
  63. $ python \-m django <command> [options]
  64. .ft P
  65. .fi
  66. .UNINDENT
  67. .UNINDENT
  68. .sp
  69. \fBcommand\fP should be one of the commands listed in this document.
  70. \fBoptions\fP, which is optional, should be zero or more of the options available
  71. for the given command.
  72. .SS Getting runtime help
  73. .INDENT 0.0
  74. .TP
  75. .B django\-admin help
  76. .UNINDENT
  77. .sp
  78. Run \fBdjango\-admin help\fP to display usage information and a list of the
  79. commands provided by each application.
  80. .sp
  81. Run \fBdjango\-admin help \-\-commands\fP to display a list of all available
  82. commands.
  83. .sp
  84. Run \fBdjango\-admin help <command>\fP to display a description of the given
  85. command and a list of its available options.
  86. .SS App names
  87. .sp
  88. Many commands take a list of "app names." An "app name" is the basename of
  89. the package containing your models. For example, if your \fBINSTALLED_APPS\fP
  90. contains the string \fB\(aqmysite.blog\(aq\fP, the app name is \fBblog\fP\&.
  91. .SS Determining the version
  92. .INDENT 0.0
  93. .TP
  94. .B django\-admin version
  95. .UNINDENT
  96. .sp
  97. Run \fBdjango\-admin version\fP to display the current Django version.
  98. .sp
  99. The output follows the schema described in \fI\%PEP 440\fP:
  100. .INDENT 0.0
  101. .INDENT 3.5
  102. .sp
  103. .nf
  104. .ft C
  105. 1.4.dev17026
  106. 1.4a1
  107. 1.4
  108. .ft P
  109. .fi
  110. .UNINDENT
  111. .UNINDENT
  112. .SS Displaying debug output
  113. .sp
  114. Use \fI\%\-\-verbosity\fP, where it is supported, to specify the amount of
  115. notification and debug information that \fBdjango\-admin\fP prints to the console.
  116. .SH AVAILABLE COMMANDS
  117. .SS \fBcheck\fP
  118. .INDENT 0.0
  119. .TP
  120. .B django\-admin check [app_label [app_label ...]]
  121. .UNINDENT
  122. .sp
  123. Uses the system check framework to inspect the entire
  124. Django project for common problems.
  125. .sp
  126. By default, all apps will be checked. You can check a subset of apps by
  127. providing a list of app labels as arguments:
  128. .INDENT 0.0
  129. .INDENT 3.5
  130. .sp
  131. .nf
  132. .ft C
  133. django\-admin check auth admin myapp
  134. .ft P
  135. .fi
  136. .UNINDENT
  137. .UNINDENT
  138. .INDENT 0.0
  139. .TP
  140. .B \-\-tag TAGS, \-t TAGS
  141. .UNINDENT
  142. .sp
  143. The system check framework performs many different types of checks that are
  144. categorized with tags\&. You can use these
  145. tags to restrict the checks performed to just those in a particular category.
  146. For example, to perform only models and compatibility checks, run:
  147. .INDENT 0.0
  148. .INDENT 3.5
  149. .sp
  150. .nf
  151. .ft C
  152. django\-admin check \-\-tag models \-\-tag compatibility
  153. .ft P
  154. .fi
  155. .UNINDENT
  156. .UNINDENT
  157. .INDENT 0.0
  158. .TP
  159. .B \-\-database DATABASE
  160. .UNINDENT
  161. .sp
  162. Specifies the database to run checks requiring database access:
  163. .INDENT 0.0
  164. .INDENT 3.5
  165. .sp
  166. .nf
  167. .ft C
  168. django\-admin check \-\-database default \-\-database other
  169. .ft P
  170. .fi
  171. .UNINDENT
  172. .UNINDENT
  173. .sp
  174. By default, these checks will not be run.
  175. .INDENT 0.0
  176. .TP
  177. .B \-\-list\-tags
  178. .UNINDENT
  179. .sp
  180. Lists all available tags.
  181. .INDENT 0.0
  182. .TP
  183. .B \-\-deploy
  184. .UNINDENT
  185. .sp
  186. Activates some additional checks that are only relevant in a deployment setting.
  187. .sp
  188. You can use this option in your local development environment, but since your
  189. local development settings module may not have many of your production settings,
  190. you will probably want to point the \fBcheck\fP command at a different settings
  191. module, either by setting the \fBDJANGO_SETTINGS_MODULE\fP environment
  192. variable, or by passing the \fB\-\-settings\fP option:
  193. .INDENT 0.0
  194. .INDENT 3.5
  195. .sp
  196. .nf
  197. .ft C
  198. django\-admin check \-\-deploy \-\-settings=production_settings
  199. .ft P
  200. .fi
  201. .UNINDENT
  202. .UNINDENT
  203. .sp
  204. Or you could run it directly on a production or staging deployment to verify
  205. that the correct settings are in use (omitting \fB\-\-settings\fP). You could even
  206. make it part of your integration test suite.
  207. .INDENT 0.0
  208. .TP
  209. .B \-\-fail\-level {CRITICAL,ERROR,WARNING,INFO,DEBUG}
  210. .UNINDENT
  211. .sp
  212. Specifies the message level that will cause the command to exit with a non\-zero
  213. status. Default is \fBERROR\fP\&.
  214. .SS \fBcompilemessages\fP
  215. .INDENT 0.0
  216. .TP
  217. .B django\-admin compilemessages
  218. .UNINDENT
  219. .sp
  220. Compiles \fB\&.po\fP files created by \fI\%makemessages\fP to \fB\&.mo\fP files for
  221. use with the built\-in gettext support. See /topics/i18n/index\&.
  222. .INDENT 0.0
  223. .TP
  224. .B \-\-locale LOCALE, \-l LOCALE
  225. .UNINDENT
  226. .sp
  227. Specifies the locale(s) to process. If not provided, all locales are processed.
  228. .INDENT 0.0
  229. .TP
  230. .B \-\-exclude EXCLUDE, \-x EXCLUDE
  231. .UNINDENT
  232. .sp
  233. Specifies the locale(s) to exclude from processing. If not provided, no locales
  234. are excluded.
  235. .INDENT 0.0
  236. .TP
  237. .B \-\-use\-fuzzy, \-f
  238. .UNINDENT
  239. .sp
  240. Includes \fI\%fuzzy translations\fP into compiled files.
  241. .sp
  242. Example usage:
  243. .INDENT 0.0
  244. .INDENT 3.5
  245. .sp
  246. .nf
  247. .ft C
  248. django\-admin compilemessages \-\-locale=pt_BR
  249. django\-admin compilemessages \-\-locale=pt_BR \-\-locale=fr \-f
  250. django\-admin compilemessages \-l pt_BR
  251. django\-admin compilemessages \-l pt_BR \-l fr \-\-use\-fuzzy
  252. django\-admin compilemessages \-\-exclude=pt_BR
  253. django\-admin compilemessages \-\-exclude=pt_BR \-\-exclude=fr
  254. django\-admin compilemessages \-x pt_BR
  255. django\-admin compilemessages \-x pt_BR \-x fr
  256. .ft P
  257. .fi
  258. .UNINDENT
  259. .UNINDENT
  260. .INDENT 0.0
  261. .TP
  262. .B \-\-ignore PATTERN, \-i PATTERN
  263. .UNINDENT
  264. .sp
  265. Ignores directories matching the given \fI\%glob\fP\-style pattern. Use
  266. multiple times to ignore more.
  267. .sp
  268. Example usage:
  269. .INDENT 0.0
  270. .INDENT 3.5
  271. .sp
  272. .nf
  273. .ft C
  274. django\-admin compilemessages \-\-ignore=cache \-\-ignore=outdated/*/locale
  275. .ft P
  276. .fi
  277. .UNINDENT
  278. .UNINDENT
  279. .SS \fBcreatecachetable\fP
  280. .INDENT 0.0
  281. .TP
  282. .B django\-admin createcachetable
  283. .UNINDENT
  284. .sp
  285. Creates the cache tables for use with the database cache backend using the
  286. information from your settings file. See /topics/cache for more
  287. information.
  288. .INDENT 0.0
  289. .TP
  290. .B \-\-database DATABASE
  291. .UNINDENT
  292. .sp
  293. Specifies the database in which the cache table(s) will be created. Defaults to
  294. \fBdefault\fP\&.
  295. .INDENT 0.0
  296. .TP
  297. .B \-\-dry\-run
  298. .UNINDENT
  299. .sp
  300. Prints the SQL that would be run without actually running it, so you can
  301. customize it or use the migrations framework.
  302. .SS \fBdbshell\fP
  303. .INDENT 0.0
  304. .TP
  305. .B django\-admin dbshell
  306. .UNINDENT
  307. .sp
  308. Runs the command\-line client for the database engine specified in your
  309. \fBENGINE\fP setting, with the connection parameters
  310. specified in your \fBUSER\fP, \fBPASSWORD\fP, etc., settings.
  311. .INDENT 0.0
  312. .IP \(bu 2
  313. For PostgreSQL, this runs the \fBpsql\fP command\-line client.
  314. .IP \(bu 2
  315. For MySQL, this runs the \fBmysql\fP command\-line client.
  316. .IP \(bu 2
  317. For SQLite, this runs the \fBsqlite3\fP command\-line client.
  318. .IP \(bu 2
  319. For Oracle, this runs the \fBsqlplus\fP command\-line client.
  320. .UNINDENT
  321. .sp
  322. This command assumes the programs are on your \fBPATH\fP so that a call to
  323. the program name (\fBpsql\fP, \fBmysql\fP, \fBsqlite3\fP, \fBsqlplus\fP) will find the
  324. program in the right place. There\(aqs no way to specify the location of the
  325. program manually.
  326. .INDENT 0.0
  327. .TP
  328. .B \-\-database DATABASE
  329. .UNINDENT
  330. .sp
  331. Specifies the database onto which to open a shell. Defaults to \fBdefault\fP\&.
  332. .INDENT 0.0
  333. .TP
  334. .B \-\- ARGUMENTS
  335. .UNINDENT
  336. .sp
  337. Any arguments following a \fB\-\-\fP divider will be passed on to the underlying
  338. command\-line client. For example, with PostgreSQL you can use the \fBpsql\fP
  339. command\(aqs \fB\-c\fP flag to execute a raw SQL query directly:
  340. .INDENT 0.0
  341. .INDENT 3.5
  342. .sp
  343. .nf
  344. .ft C
  345. $ django\-admin dbshell \-\- \-c \(aqselect current_user\(aq
  346. current_user
  347. \-\-\-\-\-\-\-\-\-\-\-\-\-\-
  348. postgres
  349. (1 row)
  350. .ft P
  351. .fi
  352. .UNINDENT
  353. .UNINDENT
  354. .sp
  355. On MySQL/MariaDB, you can do this with the \fBmysql\fP command\(aqs \fB\-e\fP flag:
  356. .INDENT 0.0
  357. .INDENT 3.5
  358. .sp
  359. .nf
  360. .ft C
  361. $ django\-admin dbshell \-\- \-e "select user()"
  362. +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+
  363. | user() |
  364. +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+
  365. | djangonaut@localhost |
  366. +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+
  367. .ft P
  368. .fi
  369. .UNINDENT
  370. .UNINDENT
  371. .sp
  372. \fBNOTE:\fP
  373. .INDENT 0.0
  374. .INDENT 3.5
  375. Be aware that not all options set in the \fBOPTIONS\fP part of your
  376. database configuration in \fBDATABASES\fP are passed to the
  377. command\-line client, e.g. \fB\(aqisolation_level\(aq\fP\&.
  378. .UNINDENT
  379. .UNINDENT
  380. .SS \fBdiffsettings\fP
  381. .INDENT 0.0
  382. .TP
  383. .B django\-admin diffsettings
  384. .UNINDENT
  385. .sp
  386. Displays differences between the current settings file and Django\(aqs default
  387. settings (or another settings file specified by \fI\%\-\-default\fP).
  388. .sp
  389. Settings that don\(aqt appear in the defaults are followed by \fB"###"\fP\&. For
  390. example, the default settings don\(aqt define \fBROOT_URLCONF\fP, so
  391. \fBROOT_URLCONF\fP is followed by \fB"###"\fP in the output of
  392. \fBdiffsettings\fP\&.
  393. .INDENT 0.0
  394. .TP
  395. .B \-\-all
  396. .UNINDENT
  397. .sp
  398. Displays all settings, even if they have Django\(aqs default value. Such settings
  399. are prefixed by \fB"###"\fP\&.
  400. .INDENT 0.0
  401. .TP
  402. .B \-\-default MODULE
  403. .UNINDENT
  404. .sp
  405. The settings module to compare the current settings against. Leave empty to
  406. compare against Django\(aqs default settings.
  407. .INDENT 0.0
  408. .TP
  409. .B \-\-output {hash,unified}
  410. .UNINDENT
  411. .sp
  412. Specifies the output format. Available values are \fBhash\fP and \fBunified\fP\&.
  413. \fBhash\fP is the default mode that displays the output that\(aqs described above.
  414. \fBunified\fP displays the output similar to \fBdiff \-u\fP\&. Default settings are
  415. prefixed with a minus sign, followed by the changed setting prefixed with a
  416. plus sign.
  417. .SS \fBdumpdata\fP
  418. .INDENT 0.0
  419. .TP
  420. .B django\-admin dumpdata [app_label[.ModelName] [app_label[.ModelName] ...]]
  421. .UNINDENT
  422. .sp
  423. Outputs to standard output all data in the database associated with the named
  424. application(s).
  425. .sp
  426. If no application name is provided, all installed applications will be dumped.
  427. .sp
  428. The output of \fBdumpdata\fP can be used as input for \fI\%loaddata\fP\&.
  429. .sp
  430. Note that \fBdumpdata\fP uses the default manager on the model for selecting the
  431. records to dump. If you\(aqre using a custom manager as
  432. the default manager and it filters some of the available records, not all of the
  433. objects will be dumped.
  434. .INDENT 0.0
  435. .TP
  436. .B \-\-all, \-a
  437. .UNINDENT
  438. .sp
  439. Uses Django\(aqs base manager, dumping records which might otherwise be filtered
  440. or modified by a custom manager.
  441. .INDENT 0.0
  442. .TP
  443. .B \-\-format FORMAT
  444. .UNINDENT
  445. .sp
  446. Specifies the serialization format of the output. Defaults to JSON. Supported
  447. formats are listed in serialization\-formats\&.
  448. .INDENT 0.0
  449. .TP
  450. .B \-\-indent INDENT
  451. .UNINDENT
  452. .sp
  453. Specifies the number of indentation spaces to use in the output. Defaults to
  454. \fBNone\fP which displays all data on single line.
  455. .INDENT 0.0
  456. .TP
  457. .B \-\-exclude EXCLUDE, \-e EXCLUDE
  458. .UNINDENT
  459. .sp
  460. Prevents specific applications or models (specified in the form of
  461. \fBapp_label.ModelName\fP) from being dumped. If you specify a model name, then
  462. only that model will be excluded, rather than the entire application. You can
  463. also mix application names and model names.
  464. .sp
  465. If you want to exclude multiple applications, pass \fB\-\-exclude\fP more than
  466. once:
  467. .INDENT 0.0
  468. .INDENT 3.5
  469. .sp
  470. .nf
  471. .ft C
  472. django\-admin dumpdata \-\-exclude=auth \-\-exclude=contenttypes
  473. .ft P
  474. .fi
  475. .UNINDENT
  476. .UNINDENT
  477. .INDENT 0.0
  478. .TP
  479. .B \-\-database DATABASE
  480. .UNINDENT
  481. .sp
  482. Specifies the database from which data will be dumped. Defaults to \fBdefault\fP\&.
  483. .INDENT 0.0
  484. .TP
  485. .B \-\-natural\-foreign
  486. .UNINDENT
  487. .sp
  488. Uses the \fBnatural_key()\fP model method to serialize any foreign key and
  489. many\-to\-many relationship to objects of the type that defines the method. If
  490. you\(aqre dumping \fBcontrib.auth\fP \fBPermission\fP objects or
  491. \fBcontrib.contenttypes\fP \fBContentType\fP objects, you should probably use this
  492. flag. See the natural keys
  493. documentation for more details on this and the next option.
  494. .INDENT 0.0
  495. .TP
  496. .B \-\-natural\-primary
  497. .UNINDENT
  498. .sp
  499. Omits the primary key in the serialized data of this object since it can be
  500. calculated during deserialization.
  501. .INDENT 0.0
  502. .TP
  503. .B \-\-pks PRIMARY_KEYS
  504. .UNINDENT
  505. .sp
  506. Outputs only the objects specified by a comma separated list of primary keys.
  507. This is only available when dumping one model. By default, all the records of
  508. the model are output.
  509. .INDENT 0.0
  510. .TP
  511. .B \-\-output OUTPUT, \-o OUTPUT
  512. .UNINDENT
  513. .sp
  514. Specifies a file to write the serialized data to. By default, the data goes to
  515. standard output.
  516. .sp
  517. When this option is set and \fB\-\-verbosity\fP is greater than 0 (the default), a
  518. progress bar is shown in the terminal.
  519. .SS Fixtures compression
  520. .sp
  521. .sp
  522. The output file can be compressed with one of the \fBbz2\fP, \fBgz\fP, \fBlzma\fP, or
  523. \fBxz\fP formats by ending the filename with the corresponding extension.
  524. For example, to output the data as a compressed JSON file:
  525. .INDENT 0.0
  526. .INDENT 3.5
  527. .sp
  528. .nf
  529. .ft C
  530. django\-admin dumpdata \-o mydata.json.gz
  531. .ft P
  532. .fi
  533. .UNINDENT
  534. .UNINDENT
  535. .SS \fBflush\fP
  536. .INDENT 0.0
  537. .TP
  538. .B django\-admin flush
  539. .UNINDENT
  540. .sp
  541. Removes all data from the database and re\-executes any post\-synchronization
  542. handlers. The table of which migrations have been applied is not cleared.
  543. .sp
  544. If you would rather start from an empty database and re\-run all migrations, you
  545. should drop and recreate the database and then run \fI\%migrate\fP instead.
  546. .INDENT 0.0
  547. .TP
  548. .B \-\-noinput, \-\-no\-input
  549. .UNINDENT
  550. .sp
  551. Suppresses all user prompts.
  552. .INDENT 0.0
  553. .TP
  554. .B \-\-database DATABASE
  555. .UNINDENT
  556. .sp
  557. Specifies the database to flush. Defaults to \fBdefault\fP\&.
  558. .SS \fBinspectdb\fP
  559. .INDENT 0.0
  560. .TP
  561. .B django\-admin inspectdb [table [table ...]]
  562. .UNINDENT
  563. .sp
  564. Introspects the database tables in the database pointed\-to by the
  565. \fBNAME\fP setting and outputs a Django model module (a \fBmodels.py\fP
  566. file) to standard output.
  567. .sp
  568. You may choose what tables or views to inspect by passing their names as
  569. arguments. If no arguments are provided, models are created for views only if
  570. the \fI\%\-\-include\-views\fP option is used. Models for partition tables are
  571. created on PostgreSQL if the \fI\%\-\-include\-partitions\fP option is used.
  572. .sp
  573. Use this if you have a legacy database with which you\(aqd like to use Django.
  574. The script will inspect the database and create a model for each table within
  575. it.
  576. .sp
  577. As you might expect, the created models will have an attribute for every field
  578. in the table. Note that \fBinspectdb\fP has a few special cases in its field\-name
  579. output:
  580. .INDENT 0.0
  581. .IP \(bu 2
  582. If \fBinspectdb\fP cannot map a column\(aqs type to a model field type, it\(aqll
  583. use \fBTextField\fP and will insert the Python comment
  584. \fB\(aqThis field type is a guess.\(aq\fP next to the field in the generated
  585. model. The recognized fields may depend on apps listed in
  586. \fBINSTALLED_APPS\fP\&. For example, \fBdjango.contrib.postgres\fP adds
  587. recognition for several PostgreSQL\-specific field types.
  588. .IP \(bu 2
  589. If the database column name is a Python reserved word (such as
  590. \fB\(aqpass\(aq\fP, \fB\(aqclass\(aq\fP or \fB\(aqfor\(aq\fP), \fBinspectdb\fP will append
  591. \fB\(aq_field\(aq\fP to the attribute name. For example, if a table has a column
  592. \fB\(aqfor\(aq\fP, the generated model will have a field \fB\(aqfor_field\(aq\fP, with
  593. the \fBdb_column\fP attribute set to \fB\(aqfor\(aq\fP\&. \fBinspectdb\fP will insert
  594. the Python comment
  595. \fB\(aqField renamed because it was a Python reserved word.\(aq\fP next to the
  596. field.
  597. .UNINDENT
  598. .sp
  599. This feature is meant as a shortcut, not as definitive model generation. After
  600. you run it, you\(aqll want to look over the generated models yourself to make
  601. customizations. In particular, you\(aqll need to rearrange models\(aq order, so that
  602. models that refer to other models are ordered properly.
  603. .sp
  604. Django doesn\(aqt create database defaults when a
  605. \fBdefault\fP is specified on a model field.
  606. Similarly, database defaults aren\(aqt translated to model field defaults or
  607. detected in any fashion by \fBinspectdb\fP\&.
  608. .sp
  609. By default, \fBinspectdb\fP creates unmanaged models. That is, \fBmanaged = False\fP
  610. in the model\(aqs \fBMeta\fP class tells Django not to manage each table\(aqs creation,
  611. modification, and deletion. If you do want to allow Django to manage the
  612. table\(aqs lifecycle, you\(aqll need to change the
  613. \fBmanaged\fP option to \fBTrue\fP (or remove
  614. it because \fBTrue\fP is its default value).
  615. .SS Database\-specific notes
  616. .SS Oracle
  617. .INDENT 0.0
  618. .IP \(bu 2
  619. Models are created for materialized views if \fI\%\-\-include\-views\fP is
  620. used.
  621. .UNINDENT
  622. .SS PostgreSQL
  623. .INDENT 0.0
  624. .IP \(bu 2
  625. Models are created for foreign tables.
  626. .IP \(bu 2
  627. Models are created for materialized views if
  628. \fI\%\-\-include\-views\fP is used.
  629. .IP \(bu 2
  630. Models are created for partition tables if
  631. \fI\%\-\-include\-partitions\fP is used.
  632. .UNINDENT
  633. .INDENT 0.0
  634. .TP
  635. .B \-\-database DATABASE
  636. .UNINDENT
  637. .sp
  638. Specifies the database to introspect. Defaults to \fBdefault\fP\&.
  639. .INDENT 0.0
  640. .TP
  641. .B \-\-include\-partitions
  642. .UNINDENT
  643. .sp
  644. If this option is provided, models are also created for partitions.
  645. .sp
  646. Only support for PostgreSQL is implemented.
  647. .INDENT 0.0
  648. .TP
  649. .B \-\-include\-views
  650. .UNINDENT
  651. .sp
  652. If this option is provided, models are also created for database views.
  653. .SS \fBloaddata\fP
  654. .INDENT 0.0
  655. .TP
  656. .B django\-admin loaddata fixture [fixture ...]
  657. .UNINDENT
  658. .sp
  659. Searches for and loads the contents of the named fixture into the database.
  660. .INDENT 0.0
  661. .TP
  662. .B \-\-database DATABASE
  663. .UNINDENT
  664. .sp
  665. Specifies the database into which the data will be loaded. Defaults to
  666. \fBdefault\fP\&.
  667. .INDENT 0.0
  668. .TP
  669. .B \-\-ignorenonexistent, \-i
  670. .UNINDENT
  671. .sp
  672. Ignores fields and models that may have been removed since the fixture was
  673. originally generated.
  674. .INDENT 0.0
  675. .TP
  676. .B \-\-app APP_LABEL
  677. .UNINDENT
  678. .sp
  679. Specifies a single app to look for fixtures in rather than looking in all apps.
  680. .INDENT 0.0
  681. .TP
  682. .B \-\-format FORMAT
  683. .UNINDENT
  684. .sp
  685. Specifies the serialization format (e.g.,
  686. \fBjson\fP or \fBxml\fP) for fixtures \fI\%read from stdin\fP\&.
  687. .INDENT 0.0
  688. .TP
  689. .B \-\-exclude EXCLUDE, \-e EXCLUDE
  690. .UNINDENT
  691. .sp
  692. Excludes loading the fixtures from the given applications and/or models (in the
  693. form of \fBapp_label\fP or \fBapp_label.ModelName\fP). Use the option multiple
  694. times to exclude more than one app or model.
  695. .SS What\(aqs a "fixture"?
  696. .sp
  697. A \fIfixture\fP is a collection of files that contain the serialized contents of
  698. the database. Each fixture has a unique name, and the files that comprise the
  699. fixture can be distributed over multiple directories, in multiple applications.
  700. .sp
  701. Django will search in three locations for fixtures:
  702. .INDENT 0.0
  703. .IP 1. 3
  704. In the \fBfixtures\fP directory of every installed application
  705. .IP 2. 3
  706. In any directory named in the \fBFIXTURE_DIRS\fP setting
  707. .IP 3. 3
  708. In the literal path named by the fixture
  709. .UNINDENT
  710. .sp
  711. Django will load any and all fixtures it finds in these locations that match
  712. the provided fixture names.
  713. .sp
  714. If the named fixture has a file extension, only fixtures of that type
  715. will be loaded. For example:
  716. .INDENT 0.0
  717. .INDENT 3.5
  718. .sp
  719. .nf
  720. .ft C
  721. django\-admin loaddata mydata.json
  722. .ft P
  723. .fi
  724. .UNINDENT
  725. .UNINDENT
  726. .sp
  727. would only load JSON fixtures called \fBmydata\fP\&. The fixture extension
  728. must correspond to the registered name of a
  729. serializer (e.g., \fBjson\fP or \fBxml\fP).
  730. .sp
  731. If you omit the extensions, Django will search all available fixture types
  732. for a matching fixture. For example:
  733. .INDENT 0.0
  734. .INDENT 3.5
  735. .sp
  736. .nf
  737. .ft C
  738. django\-admin loaddata mydata
  739. .ft P
  740. .fi
  741. .UNINDENT
  742. .UNINDENT
  743. .sp
  744. would look for any fixture of any fixture type called \fBmydata\fP\&. If a fixture
  745. directory contained \fBmydata.json\fP, that fixture would be loaded
  746. as a JSON fixture.
  747. .sp
  748. The fixtures that are named can include directory components. These
  749. directories will be included in the search path. For example:
  750. .INDENT 0.0
  751. .INDENT 3.5
  752. .sp
  753. .nf
  754. .ft C
  755. django\-admin loaddata foo/bar/mydata.json
  756. .ft P
  757. .fi
  758. .UNINDENT
  759. .UNINDENT
  760. .sp
  761. would search \fB<app_label>/fixtures/foo/bar/mydata.json\fP for each installed
  762. application, \fB<dirname>/foo/bar/mydata.json\fP for each directory in
  763. \fBFIXTURE_DIRS\fP, and the literal path \fBfoo/bar/mydata.json\fP\&.
  764. .sp
  765. When fixture files are processed, the data is saved to the database as is.
  766. Model defined \fBsave()\fP methods are not called, and
  767. any \fBpre_save\fP or
  768. \fBpost_save\fP signals will be called with
  769. \fBraw=True\fP since the instance only contains attributes that are local to the
  770. model. You may, for example, want to disable handlers that access
  771. related fields that aren\(aqt present during fixture loading and would otherwise
  772. raise an exception:
  773. .INDENT 0.0
  774. .INDENT 3.5
  775. .sp
  776. .nf
  777. .ft C
  778. from django.db.models.signals import post_save
  779. from .models import MyModel
  780. def my_handler(**kwargs):
  781. # disable the handler during fixture loading
  782. if kwargs[\(aqraw\(aq]:
  783. return
  784. ...
  785. post_save.connect(my_handler, sender=MyModel)
  786. .ft P
  787. .fi
  788. .UNINDENT
  789. .UNINDENT
  790. .sp
  791. You could also write a decorator to encapsulate this logic:
  792. .INDENT 0.0
  793. .INDENT 3.5
  794. .sp
  795. .nf
  796. .ft C
  797. from functools import wraps
  798. def disable_for_loaddata(signal_handler):
  799. """
  800. Decorator that turns off signal handlers when loading fixture data.
  801. """
  802. @wraps(signal_handler)
  803. def wrapper(*args, **kwargs):
  804. if kwargs[\(aqraw\(aq]:
  805. return
  806. signal_handler(*args, **kwargs)
  807. return wrapper
  808. @disable_for_loaddata
  809. def my_handler(**kwargs):
  810. ...
  811. .ft P
  812. .fi
  813. .UNINDENT
  814. .UNINDENT
  815. .sp
  816. Just be aware that this logic will disable the signals whenever fixtures are
  817. deserialized, not just during \fBloaddata\fP\&.
  818. .sp
  819. Note that the order in which fixture files are processed is undefined. However,
  820. all fixture data is installed as a single transaction, so data in
  821. one fixture can reference data in another fixture. If the database backend
  822. supports row\-level constraints, these constraints will be checked at the
  823. end of the transaction.
  824. .sp
  825. The \fI\%dumpdata\fP command can be used to generate input for \fBloaddata\fP\&.
  826. .SS Compressed fixtures
  827. .sp
  828. Fixtures may be compressed in \fBzip\fP, \fBgz\fP, \fBbz2\fP, \fBlzma\fP, or \fBxz\fP
  829. format. For example:
  830. .INDENT 0.0
  831. .INDENT 3.5
  832. .sp
  833. .nf
  834. .ft C
  835. django\-admin loaddata mydata.json
  836. .ft P
  837. .fi
  838. .UNINDENT
  839. .UNINDENT
  840. .sp
  841. would look for any of \fBmydata.json\fP, \fBmydata.json.zip\fP, \fBmydata.json.gz\fP,
  842. \fBmydata.json.bz2\fP, \fBmydata.json.lzma\fP, or \fBmydata.json.xz\fP\&. The first
  843. file contained within a compressed archive is used.
  844. .sp
  845. Note that if two fixtures with the same name but different
  846. fixture type are discovered (for example, if \fBmydata.json\fP and
  847. \fBmydata.xml.gz\fP were found in the same fixture directory), fixture
  848. installation will be aborted, and any data installed in the call to
  849. \fBloaddata\fP will be removed from the database.
  850. .INDENT 0.0
  851. .INDENT 3.5
  852. .IP "MySQL with MyISAM and fixtures"
  853. .sp
  854. The MyISAM storage engine of MySQL doesn\(aqt support transactions or
  855. constraints, so if you use MyISAM, you won\(aqt get validation of fixture
  856. data, or a rollback if multiple transaction files are found.
  857. .UNINDENT
  858. .UNINDENT
  859. .sp
  860. Support for XZ archives (\fB\&.xz\fP) and LZMA archives (\fB\&.lzma\fP) was added.
  861. .SS Database\-specific fixtures
  862. .sp
  863. If you\(aqre in a multi\-database setup, you might have fixture data that
  864. you want to load onto one database, but not onto another. In this
  865. situation, you can add a database identifier into the names of your fixtures.
  866. .sp
  867. For example, if your \fBDATABASES\fP setting has a \(aqusers\(aq database
  868. defined, name the fixture \fBmydata.users.json\fP or
  869. \fBmydata.users.json.gz\fP and the fixture will only be loaded when you
  870. specify you want to load data into the \fBmaster\fP database.
  871. .SS Loading fixtures from \fBstdin\fP
  872. .sp
  873. You can use a dash as the fixture name to load input from \fBsys.stdin\fP\&. For
  874. example:
  875. .INDENT 0.0
  876. .INDENT 3.5
  877. .sp
  878. .nf
  879. .ft C
  880. django\-admin loaddata \-\-format=json \-
  881. .ft P
  882. .fi
  883. .UNINDENT
  884. .UNINDENT
  885. .sp
  886. When reading from \fBstdin\fP, the \fI\%\-\-format\fP option
  887. is required to specify the serialization format
  888. of the input (e.g., \fBjson\fP or \fBxml\fP).
  889. .sp
  890. Loading from \fBstdin\fP is useful with standard input and output redirections.
  891. For example:
  892. .INDENT 0.0
  893. .INDENT 3.5
  894. .sp
  895. .nf
  896. .ft C
  897. django\-admin dumpdata \-\-format=json \-\-database=test app_label.ModelName | django\-admin loaddata \-\-format=json \-\-database=prod \-
  898. .ft P
  899. .fi
  900. .UNINDENT
  901. .UNINDENT
  902. .SS \fBmakemessages\fP
  903. .INDENT 0.0
  904. .TP
  905. .B django\-admin makemessages
  906. .UNINDENT
  907. .sp
  908. Runs over the entire source tree of the current directory and pulls out all
  909. strings marked for translation. It creates (or updates) a message file in the
  910. conf/locale (in the Django tree) or locale (for project and application)
  911. directory. After making changes to the messages files you need to compile them
  912. with \fI\%compilemessages\fP for use with the builtin gettext support. See
  913. the i18n documentation for details.
  914. .sp
  915. This command doesn\(aqt require configured settings. However, when settings aren\(aqt
  916. configured, the command can\(aqt ignore the \fBMEDIA_ROOT\fP and
  917. \fBSTATIC_ROOT\fP directories or include \fBLOCALE_PATHS\fP\&.
  918. .INDENT 0.0
  919. .TP
  920. .B \-\-all, \-a
  921. .UNINDENT
  922. .sp
  923. Updates the message files for all available languages.
  924. .INDENT 0.0
  925. .TP
  926. .B \-\-extension EXTENSIONS, \-e EXTENSIONS
  927. .UNINDENT
  928. .sp
  929. Specifies a list of file extensions to examine (default: \fBhtml\fP, \fBtxt\fP,
  930. \fBpy\fP or \fBjs\fP if \fI\%\-\-domain\fP is \fBjs\fP).
  931. .sp
  932. Example usage:
  933. .INDENT 0.0
  934. .INDENT 3.5
  935. .sp
  936. .nf
  937. .ft C
  938. django\-admin makemessages \-\-locale=de \-\-extension xhtml
  939. .ft P
  940. .fi
  941. .UNINDENT
  942. .UNINDENT
  943. .sp
  944. Separate multiple extensions with commas or use \fB\-e\fP or \fB\-\-extension\fP
  945. multiple times:
  946. .INDENT 0.0
  947. .INDENT 3.5
  948. .sp
  949. .nf
  950. .ft C
  951. django\-admin makemessages \-\-locale=de \-\-extension=html,txt \-\-extension xml
  952. .ft P
  953. .fi
  954. .UNINDENT
  955. .UNINDENT
  956. .INDENT 0.0
  957. .TP
  958. .B \-\-locale LOCALE, \-l LOCALE
  959. .UNINDENT
  960. .sp
  961. Specifies the locale(s) to process.
  962. .INDENT 0.0
  963. .TP
  964. .B \-\-exclude EXCLUDE, \-x EXCLUDE
  965. .UNINDENT
  966. .sp
  967. Specifies the locale(s) to exclude from processing. If not provided, no locales
  968. are excluded.
  969. .sp
  970. Example usage:
  971. .INDENT 0.0
  972. .INDENT 3.5
  973. .sp
  974. .nf
  975. .ft C
  976. django\-admin makemessages \-\-locale=pt_BR
  977. django\-admin makemessages \-\-locale=pt_BR \-\-locale=fr
  978. django\-admin makemessages \-l pt_BR
  979. django\-admin makemessages \-l pt_BR \-l fr
  980. django\-admin makemessages \-\-exclude=pt_BR
  981. django\-admin makemessages \-\-exclude=pt_BR \-\-exclude=fr
  982. django\-admin makemessages \-x pt_BR
  983. django\-admin makemessages \-x pt_BR \-x fr
  984. .ft P
  985. .fi
  986. .UNINDENT
  987. .UNINDENT
  988. .INDENT 0.0
  989. .TP
  990. .B \-\-domain DOMAIN, \-d DOMAIN
  991. .UNINDENT
  992. .sp
  993. Specifies the domain of the messages files. Supported options are:
  994. .INDENT 0.0
  995. .IP \(bu 2
  996. \fBdjango\fP for all \fB*.py\fP, \fB*.html\fP and \fB*.txt\fP files (default)
  997. .IP \(bu 2
  998. \fBdjangojs\fP for \fB*.js\fP files
  999. .UNINDENT
  1000. .INDENT 0.0
  1001. .TP
  1002. .B \-\-symlinks, \-s
  1003. .UNINDENT
  1004. .sp
  1005. Follows symlinks to directories when looking for new translation strings.
  1006. .sp
  1007. Example usage:
  1008. .INDENT 0.0
  1009. .INDENT 3.5
  1010. .sp
  1011. .nf
  1012. .ft C
  1013. django\-admin makemessages \-\-locale=de \-\-symlinks
  1014. .ft P
  1015. .fi
  1016. .UNINDENT
  1017. .UNINDENT
  1018. .INDENT 0.0
  1019. .TP
  1020. .B \-\-ignore PATTERN, \-i PATTERN
  1021. .UNINDENT
  1022. .sp
  1023. Ignores files or directories matching the given \fI\%glob\fP\-style pattern. Use
  1024. multiple times to ignore more.
  1025. .sp
  1026. These patterns are used by default: \fB\(aqCVS\(aq\fP, \fB\(aq.*\(aq\fP, \fB\(aq*~\(aq\fP, \fB\(aq*.pyc\(aq\fP\&.
  1027. .sp
  1028. Example usage:
  1029. .INDENT 0.0
  1030. .INDENT 3.5
  1031. .sp
  1032. .nf
  1033. .ft C
  1034. django\-admin makemessages \-\-locale=en_US \-\-ignore=apps/* \-\-ignore=secret/*.html
  1035. .ft P
  1036. .fi
  1037. .UNINDENT
  1038. .UNINDENT
  1039. .INDENT 0.0
  1040. .TP
  1041. .B \-\-no\-default\-ignore
  1042. .UNINDENT
  1043. .sp
  1044. Disables the default values of \fB\-\-ignore\fP\&.
  1045. .INDENT 0.0
  1046. .TP
  1047. .B \-\-no\-wrap
  1048. .UNINDENT
  1049. .sp
  1050. Disables breaking long message lines into several lines in language files.
  1051. .INDENT 0.0
  1052. .TP
  1053. .B \-\-no\-location
  1054. .UNINDENT
  1055. .sp
  1056. Suppresses writing \(aq\fB#: filename:line\fP’ comment lines in language files.
  1057. Using this option makes it harder for technically skilled translators to
  1058. understand each message\(aqs context.
  1059. .INDENT 0.0
  1060. .TP
  1061. .B \-\-add\-location [{full,file,never}]
  1062. .UNINDENT
  1063. .sp
  1064. Controls \fB#: filename:line\fP comment lines in language files. If the option
  1065. is:
  1066. .INDENT 0.0
  1067. .IP \(bu 2
  1068. \fBfull\fP (the default if not given): the lines include both file name and
  1069. line number.
  1070. .IP \(bu 2
  1071. \fBfile\fP: the line number is omitted.
  1072. .IP \(bu 2
  1073. \fBnever\fP: the lines are suppressed (same as \fI\%\-\-no\-location\fP).
  1074. .UNINDENT
  1075. .sp
  1076. Requires \fBgettext\fP 0.19 or newer.
  1077. .INDENT 0.0
  1078. .TP
  1079. .B \-\-keep\-pot
  1080. .UNINDENT
  1081. .sp
  1082. Prevents deleting the temporary \fB\&.pot\fP files generated before creating the
  1083. \fB\&.po\fP file. This is useful for debugging errors which may prevent the final
  1084. language files from being created.
  1085. .sp
  1086. \fBSEE ALSO:\fP
  1087. .INDENT 0.0
  1088. .INDENT 3.5
  1089. See customizing\-makemessages for instructions on how to customize
  1090. the keywords that \fI\%makemessages\fP passes to \fBxgettext\fP\&.
  1091. .UNINDENT
  1092. .UNINDENT
  1093. .SS \fBmakemigrations\fP
  1094. .INDENT 0.0
  1095. .TP
  1096. .B django\-admin makemigrations [app_label [app_label ...]]
  1097. .UNINDENT
  1098. .sp
  1099. Creates new migrations based on the changes detected to your models.
  1100. Migrations, their relationship with apps and more are covered in depth in
  1101. the migrations documentation\&.
  1102. .sp
  1103. Providing one or more app names as arguments will limit the migrations created
  1104. to the app(s) specified and any dependencies needed (the table at the other end
  1105. of a \fBForeignKey\fP, for example).
  1106. .sp
  1107. To add migrations to an app that doesn\(aqt have a \fBmigrations\fP directory, run
  1108. \fBmakemigrations\fP with the app\(aqs \fBapp_label\fP\&.
  1109. .INDENT 0.0
  1110. .TP
  1111. .B \-\-noinput, \-\-no\-input
  1112. .UNINDENT
  1113. .sp
  1114. Suppresses all user prompts. If a suppressed prompt cannot be resolved
  1115. automatically, the command will exit with error code 3.
  1116. .INDENT 0.0
  1117. .TP
  1118. .B \-\-empty
  1119. .UNINDENT
  1120. .sp
  1121. Outputs an empty migration for the specified apps, for manual editing. This is
  1122. for advanced users and should not be used unless you are familiar with the
  1123. migration format, migration operations, and the dependencies between your
  1124. migrations.
  1125. .INDENT 0.0
  1126. .TP
  1127. .B \-\-dry\-run
  1128. .UNINDENT
  1129. .sp
  1130. Shows what migrations would be made without actually writing any migrations
  1131. files to disk. Using this option along with \fB\-\-verbosity 3\fP will also show
  1132. the complete migrations files that would be written.
  1133. .INDENT 0.0
  1134. .TP
  1135. .B \-\-merge
  1136. .UNINDENT
  1137. .sp
  1138. Enables fixing of migration conflicts.
  1139. .INDENT 0.0
  1140. .TP
  1141. .B \-\-name NAME, \-n NAME
  1142. .UNINDENT
  1143. .sp
  1144. Allows naming the generated migration(s) instead of using a generated name. The
  1145. name must be a valid Python \fI\%identifier\fP\&.
  1146. .INDENT 0.0
  1147. .TP
  1148. .B \-\-no\-header
  1149. .UNINDENT
  1150. .sp
  1151. Generate migration files without Django version and timestamp header.
  1152. .INDENT 0.0
  1153. .TP
  1154. .B \-\-check
  1155. .UNINDENT
  1156. .sp
  1157. Makes \fBmakemigrations\fP exit with a non\-zero status when model changes without
  1158. migrations are detected.
  1159. .sp
  1160. Support for calling \fBmakemigrations\fP without an active database
  1161. connection was added. In that case, check for a consistent migration
  1162. history is skipped.
  1163. .SS \fBmigrate\fP
  1164. .INDENT 0.0
  1165. .TP
  1166. .B django\-admin migrate [app_label] [migration_name]
  1167. .UNINDENT
  1168. .sp
  1169. Synchronizes the database state with the current set of models and migrations.
  1170. Migrations, their relationship with apps and more are covered in depth in
  1171. the migrations documentation\&.
  1172. .sp
  1173. The behavior of this command changes depending on the arguments provided:
  1174. .INDENT 0.0
  1175. .IP \(bu 2
  1176. No arguments: All apps have all of their migrations run.
  1177. .IP \(bu 2
  1178. \fB<app_label>\fP: The specified app has its migrations run, up to the most
  1179. recent migration. This may involve running other apps\(aq migrations too, due
  1180. to dependencies.
  1181. .IP \(bu 2
  1182. \fB<app_label> <migrationname>\fP: Brings the database schema to a state where
  1183. the named migration is applied, but no later migrations in the same app are
  1184. applied. This may involve unapplying migrations if you have previously
  1185. migrated past the named migration. You can use a prefix of the migration
  1186. name, e.g. \fB0001\fP, as long as it\(aqs unique for the given app name. Use the
  1187. name \fBzero\fP to migrate all the way back i.e. to revert all applied
  1188. migrations for an app.
  1189. .UNINDENT
  1190. .sp
  1191. \fBWARNING:\fP
  1192. .INDENT 0.0
  1193. .INDENT 3.5
  1194. When unapplying migrations, all dependent migrations will also be
  1195. unapplied, regardless of \fB<app_label>\fP\&. You can use \fB\-\-plan\fP to check
  1196. which migrations will be unapplied.
  1197. .UNINDENT
  1198. .UNINDENT
  1199. .INDENT 0.0
  1200. .TP
  1201. .B \-\-database DATABASE
  1202. .UNINDENT
  1203. .sp
  1204. Specifies the database to migrate. Defaults to \fBdefault\fP\&.
  1205. .INDENT 0.0
  1206. .TP
  1207. .B \-\-fake
  1208. .UNINDENT
  1209. .sp
  1210. Marks the migrations up to the target one (following the rules above) as
  1211. applied, but without actually running the SQL to change your database schema.
  1212. .sp
  1213. This is intended for advanced users to manipulate the
  1214. current migration state directly if they\(aqre manually applying changes;
  1215. be warned that using \fB\-\-fake\fP runs the risk of putting the migration state
  1216. table into a state where manual recovery will be needed to make migrations
  1217. run correctly.
  1218. .INDENT 0.0
  1219. .TP
  1220. .B \-\-fake\-initial
  1221. .UNINDENT
  1222. .sp
  1223. Allows Django to skip an app\(aqs initial migration if all database tables with
  1224. the names of all models created by all
  1225. \fBCreateModel\fP operations in that
  1226. migration already exist. This option is intended for use when first running
  1227. migrations against a database that preexisted the use of migrations. This
  1228. option does not, however, check for matching database schema beyond matching
  1229. table names and so is only safe to use if you are confident that your existing
  1230. schema matches what is recorded in your initial migration.
  1231. .INDENT 0.0
  1232. .TP
  1233. .B \-\-plan
  1234. .UNINDENT
  1235. .sp
  1236. Shows the migration operations that will be performed for the given \fBmigrate\fP
  1237. command.
  1238. .INDENT 0.0
  1239. .TP
  1240. .B \-\-run\-syncdb
  1241. .UNINDENT
  1242. .sp
  1243. Allows creating tables for apps without migrations. While this isn\(aqt
  1244. recommended, the migrations framework is sometimes too slow on large projects
  1245. with hundreds of models.
  1246. .INDENT 0.0
  1247. .TP
  1248. .B \-\-noinput, \-\-no\-input
  1249. .UNINDENT
  1250. .sp
  1251. Suppresses all user prompts. An example prompt is asking about removing stale
  1252. content types.
  1253. .INDENT 0.0
  1254. .TP
  1255. .B \-\-check
  1256. .UNINDENT
  1257. .sp
  1258. Makes \fBmigrate\fP exit with a non\-zero status when unapplied migrations are
  1259. detected.
  1260. .SS \fBrunserver\fP
  1261. .INDENT 0.0
  1262. .TP
  1263. .B django\-admin runserver [addrport]
  1264. .UNINDENT
  1265. .sp
  1266. Starts a lightweight development web server on the local machine. By default,
  1267. the server runs on port 8000 on the IP address \fB127.0.0.1\fP\&. You can pass in an
  1268. IP address and port number explicitly.
  1269. .sp
  1270. If you run this script as a user with normal privileges (recommended), you
  1271. might not have access to start a port on a low port number. Low port numbers
  1272. are reserved for the superuser (root).
  1273. .sp
  1274. This server uses the WSGI application object specified by the
  1275. \fBWSGI_APPLICATION\fP setting.
  1276. .sp
  1277. DO NOT USE THIS SERVER IN A PRODUCTION SETTING. It has not gone through
  1278. security audits or performance tests. (And that\(aqs how it\(aqs gonna stay. We\(aqre in
  1279. the business of making web frameworks, not web servers, so improving this
  1280. server to be able to handle a production environment is outside the scope of
  1281. Django.)
  1282. .sp
  1283. The development server automatically reloads Python code for each request, as
  1284. needed. You don\(aqt need to restart the server for code changes to take effect.
  1285. However, some actions like adding files don\(aqt trigger a restart, so you\(aqll
  1286. have to restart the server in these cases.
  1287. .sp
  1288. If you\(aqre using Linux or MacOS and install both \fI\%pywatchman\fP and the
  1289. \fI\%Watchman\fP service, kernel signals will be used to autoreload the server
  1290. (rather than polling file modification timestamps each second). This offers
  1291. better performance on large projects, reduced response time after code changes,
  1292. more robust change detection, and a reduction in power usage. Django supports
  1293. \fBpywatchman\fP 1.2.0 and higher.
  1294. .INDENT 0.0
  1295. .INDENT 3.5
  1296. .IP "Large directories with many files may cause performance issues"
  1297. .sp
  1298. When using Watchman with a project that includes large non\-Python
  1299. directories like \fBnode_modules\fP, it\(aqs advisable to ignore this directory
  1300. for optimal performance. See the \fI\%watchman documentation\fP for information
  1301. on how to do this.
  1302. .UNINDENT
  1303. .UNINDENT
  1304. .INDENT 0.0
  1305. .INDENT 3.5
  1306. .IP "Watchman timeout"
  1307. .INDENT 0.0
  1308. .TP
  1309. .B DJANGO_WATCHMAN_TIMEOUT
  1310. .UNINDENT
  1311. .sp
  1312. The default timeout of \fBWatchman\fP client is 5 seconds. You can change it
  1313. by setting the \fI\%DJANGO_WATCHMAN_TIMEOUT\fP environment variable.
  1314. .UNINDENT
  1315. .UNINDENT
  1316. .sp
  1317. When you start the server, and each time you change Python code while the
  1318. server is running, the system check framework will check your entire Django
  1319. project for some common errors (see the \fI\%check\fP command). If any
  1320. errors are found, they will be printed to standard output. You can use the
  1321. \fB\-\-skip\-checks\fP option to skip running system checks.
  1322. .sp
  1323. You can run as many concurrent servers as you want, as long as they\(aqre on
  1324. separate ports by executing \fBdjango\-admin runserver\fP more than once.
  1325. .sp
  1326. Note that the default IP address, \fB127.0.0.1\fP, is not accessible from other
  1327. machines on your network. To make your development server viewable to other
  1328. machines on the network, use its own IP address (e.g. \fB192.168.2.1\fP) or
  1329. \fB0.0.0.0\fP or \fB::\fP (with IPv6 enabled).
  1330. .sp
  1331. You can provide an IPv6 address surrounded by brackets
  1332. (e.g. \fB[200a::1]:8000\fP). This will automatically enable IPv6 support.
  1333. .sp
  1334. A hostname containing ASCII\-only characters can also be used.
  1335. .sp
  1336. If the staticfiles contrib app is enabled
  1337. (default in new projects) the \fI\%runserver\fP command will be overridden
  1338. with its own runserver command.
  1339. .sp
  1340. Logging of each request and response of the server is sent to the
  1341. django\-server\-logger logger.
  1342. .INDENT 0.0
  1343. .TP
  1344. .B \-\-noreload
  1345. .UNINDENT
  1346. .sp
  1347. Disables the auto\-reloader. This means any Python code changes you make while
  1348. the server is running will \fInot\fP take effect if the particular Python modules
  1349. have already been loaded into memory.
  1350. .INDENT 0.0
  1351. .TP
  1352. .B \-\-nothreading
  1353. .UNINDENT
  1354. .sp
  1355. Disables use of threading in the development server. The server is
  1356. multithreaded by default.
  1357. .INDENT 0.0
  1358. .TP
  1359. .B \-\-ipv6, \-6
  1360. .UNINDENT
  1361. .sp
  1362. Uses IPv6 for the development server. This changes the default IP address from
  1363. \fB127.0.0.1\fP to \fB::1\fP\&.
  1364. .sp
  1365. Support for the \fB\-\-skip\-checks\fP option was added.
  1366. .SS Examples of using different ports and addresses
  1367. .sp
  1368. Port 8000 on IP address \fB127.0.0.1\fP:
  1369. .INDENT 0.0
  1370. .INDENT 3.5
  1371. .sp
  1372. .nf
  1373. .ft C
  1374. django\-admin runserver
  1375. .ft P
  1376. .fi
  1377. .UNINDENT
  1378. .UNINDENT
  1379. .sp
  1380. Port 8000 on IP address \fB1.2.3.4\fP:
  1381. .INDENT 0.0
  1382. .INDENT 3.5
  1383. .sp
  1384. .nf
  1385. .ft C
  1386. django\-admin runserver 1.2.3.4:8000
  1387. .ft P
  1388. .fi
  1389. .UNINDENT
  1390. .UNINDENT
  1391. .sp
  1392. Port 7000 on IP address \fB127.0.0.1\fP:
  1393. .INDENT 0.0
  1394. .INDENT 3.5
  1395. .sp
  1396. .nf
  1397. .ft C
  1398. django\-admin runserver 7000
  1399. .ft P
  1400. .fi
  1401. .UNINDENT
  1402. .UNINDENT
  1403. .sp
  1404. Port 7000 on IP address \fB1.2.3.4\fP:
  1405. .INDENT 0.0
  1406. .INDENT 3.5
  1407. .sp
  1408. .nf
  1409. .ft C
  1410. django\-admin runserver 1.2.3.4:7000
  1411. .ft P
  1412. .fi
  1413. .UNINDENT
  1414. .UNINDENT
  1415. .sp
  1416. Port 8000 on IPv6 address \fB::1\fP:
  1417. .INDENT 0.0
  1418. .INDENT 3.5
  1419. .sp
  1420. .nf
  1421. .ft C
  1422. django\-admin runserver \-6
  1423. .ft P
  1424. .fi
  1425. .UNINDENT
  1426. .UNINDENT
  1427. .sp
  1428. Port 7000 on IPv6 address \fB::1\fP:
  1429. .INDENT 0.0
  1430. .INDENT 3.5
  1431. .sp
  1432. .nf
  1433. .ft C
  1434. django\-admin runserver \-6 7000
  1435. .ft P
  1436. .fi
  1437. .UNINDENT
  1438. .UNINDENT
  1439. .sp
  1440. Port 7000 on IPv6 address \fB2001:0db8:1234:5678::9\fP:
  1441. .INDENT 0.0
  1442. .INDENT 3.5
  1443. .sp
  1444. .nf
  1445. .ft C
  1446. django\-admin runserver [2001:0db8:1234:5678::9]:7000
  1447. .ft P
  1448. .fi
  1449. .UNINDENT
  1450. .UNINDENT
  1451. .sp
  1452. Port 8000 on IPv4 address of host \fBlocalhost\fP:
  1453. .INDENT 0.0
  1454. .INDENT 3.5
  1455. .sp
  1456. .nf
  1457. .ft C
  1458. django\-admin runserver localhost:8000
  1459. .ft P
  1460. .fi
  1461. .UNINDENT
  1462. .UNINDENT
  1463. .sp
  1464. Port 8000 on IPv6 address of host \fBlocalhost\fP:
  1465. .INDENT 0.0
  1466. .INDENT 3.5
  1467. .sp
  1468. .nf
  1469. .ft C
  1470. django\-admin runserver \-6 localhost:8000
  1471. .ft P
  1472. .fi
  1473. .UNINDENT
  1474. .UNINDENT
  1475. .SS Serving static files with the development server
  1476. .sp
  1477. By default, the development server doesn\(aqt serve any static files for your site
  1478. (such as CSS files, images, things under \fBMEDIA_URL\fP and so forth). If
  1479. you want to configure Django to serve static media, read
  1480. /howto/static\-files/index\&.
  1481. .SS \fBsendtestemail\fP
  1482. .INDENT 0.0
  1483. .TP
  1484. .B django\-admin sendtestemail [email [email ...]]
  1485. .UNINDENT
  1486. .sp
  1487. Sends a test email (to confirm email sending through Django is working) to the
  1488. recipient(s) specified. For example:
  1489. .INDENT 0.0
  1490. .INDENT 3.5
  1491. .sp
  1492. .nf
  1493. .ft C
  1494. django\-admin sendtestemail foo@example.com bar@example.com
  1495. .ft P
  1496. .fi
  1497. .UNINDENT
  1498. .UNINDENT
  1499. .sp
  1500. There are a couple of options, and you may use any combination of them
  1501. together:
  1502. .INDENT 0.0
  1503. .TP
  1504. .B \-\-managers
  1505. .UNINDENT
  1506. .sp
  1507. Mails the email addresses specified in \fBMANAGERS\fP using
  1508. \fBmail_managers()\fP\&.
  1509. .INDENT 0.0
  1510. .TP
  1511. .B \-\-admins
  1512. .UNINDENT
  1513. .sp
  1514. Mails the email addresses specified in \fBADMINS\fP using
  1515. \fBmail_admins()\fP\&.
  1516. .SS \fBshell\fP
  1517. .INDENT 0.0
  1518. .TP
  1519. .B django\-admin shell
  1520. .UNINDENT
  1521. .sp
  1522. Starts the Python interactive interpreter.
  1523. .INDENT 0.0
  1524. .TP
  1525. .B \-\-interface {ipython,bpython,python}, \-i {ipython,bpython,python}
  1526. .UNINDENT
  1527. .sp
  1528. Specifies the shell to use. By default, Django will use \fI\%IPython\fP or \fI\%bpython\fP if
  1529. either is installed. If both are installed, specify which one you want like so:
  1530. .sp
  1531. IPython:
  1532. .INDENT 0.0
  1533. .INDENT 3.5
  1534. .sp
  1535. .nf
  1536. .ft C
  1537. django\-admin shell \-i ipython
  1538. .ft P
  1539. .fi
  1540. .UNINDENT
  1541. .UNINDENT
  1542. .sp
  1543. bpython:
  1544. .INDENT 0.0
  1545. .INDENT 3.5
  1546. .sp
  1547. .nf
  1548. .ft C
  1549. django\-admin shell \-i bpython
  1550. .ft P
  1551. .fi
  1552. .UNINDENT
  1553. .UNINDENT
  1554. .sp
  1555. If you have a "rich" shell installed but want to force use of the "plain"
  1556. Python interpreter, use \fBpython\fP as the interface name, like so:
  1557. .INDENT 0.0
  1558. .INDENT 3.5
  1559. .sp
  1560. .nf
  1561. .ft C
  1562. django\-admin shell \-i python
  1563. .ft P
  1564. .fi
  1565. .UNINDENT
  1566. .UNINDENT
  1567. .INDENT 0.0
  1568. .TP
  1569. .B \-\-nostartup
  1570. .UNINDENT
  1571. .sp
  1572. Disables reading the startup script for the "plain" Python interpreter. By
  1573. default, the script pointed to by the \fI\%PYTHONSTARTUP\fP environment
  1574. variable or the \fB~/.pythonrc.py\fP script is read.
  1575. .INDENT 0.0
  1576. .TP
  1577. .B \-\-command COMMAND, \-c COMMAND
  1578. .UNINDENT
  1579. .sp
  1580. Lets you pass a command as a string to execute it as Django, like so:
  1581. .INDENT 0.0
  1582. .INDENT 3.5
  1583. .sp
  1584. .nf
  1585. .ft C
  1586. django\-admin shell \-\-command="import django; print(django.__version__)"
  1587. .ft P
  1588. .fi
  1589. .UNINDENT
  1590. .UNINDENT
  1591. .sp
  1592. You can also pass code in on standard input to execute it. For example:
  1593. .INDENT 0.0
  1594. .INDENT 3.5
  1595. .sp
  1596. .nf
  1597. .ft C
  1598. $ django\-admin shell <<EOF
  1599. > import django
  1600. > print(django.__version__)
  1601. > EOF
  1602. .ft P
  1603. .fi
  1604. .UNINDENT
  1605. .UNINDENT
  1606. .sp
  1607. On Windows, the REPL is output due to implementation limits of
  1608. \fI\%select.select()\fP on that platform.
  1609. .SS \fBshowmigrations\fP
  1610. .INDENT 0.0
  1611. .TP
  1612. .B django\-admin showmigrations [app_label [app_label ...]]
  1613. .UNINDENT
  1614. .sp
  1615. Shows all migrations in a project. You can choose from one of two formats:
  1616. .INDENT 0.0
  1617. .TP
  1618. .B \-\-list, \-l
  1619. .UNINDENT
  1620. .sp
  1621. Lists all of the apps Django knows about, the migrations available for each
  1622. app, and whether or not each migration is applied (marked by an \fB[X]\fP next to
  1623. the migration name). For a \fB\-\-verbosity\fP of 2 and above, the applied
  1624. datetimes are also shown.
  1625. .sp
  1626. Apps without migrations are also listed, but have \fB(no migrations)\fP printed
  1627. under them.
  1628. .sp
  1629. This is the default output format.
  1630. .INDENT 0.0
  1631. .TP
  1632. .B \-\-plan, \-p
  1633. .UNINDENT
  1634. .sp
  1635. Shows the migration plan Django will follow to apply migrations. Like
  1636. \fB\-\-list\fP, applied migrations are marked by an \fB[X]\fP\&. For a \fB\-\-verbosity\fP
  1637. of 2 and above, all dependencies of a migration will also be shown.
  1638. .sp
  1639. \fBapp_label\fPs arguments limit the output, however, dependencies of provided
  1640. apps may also be included.
  1641. .INDENT 0.0
  1642. .TP
  1643. .B \-\-database DATABASE
  1644. .UNINDENT
  1645. .sp
  1646. Specifies the database to examine. Defaults to \fBdefault\fP\&.
  1647. .SS \fBsqlflush\fP
  1648. .INDENT 0.0
  1649. .TP
  1650. .B django\-admin sqlflush
  1651. .UNINDENT
  1652. .sp
  1653. Prints the SQL statements that would be executed for the \fI\%flush\fP
  1654. command.
  1655. .INDENT 0.0
  1656. .TP
  1657. .B \-\-database DATABASE
  1658. .UNINDENT
  1659. .sp
  1660. Specifies the database for which to print the SQL. Defaults to \fBdefault\fP\&.
  1661. .SS \fBsqlmigrate\fP
  1662. .INDENT 0.0
  1663. .TP
  1664. .B django\-admin sqlmigrate app_label migration_name
  1665. .UNINDENT
  1666. .sp
  1667. Prints the SQL for the named migration. This requires an active database
  1668. connection, which it will use to resolve constraint names; this means you must
  1669. generate the SQL against a copy of the database you wish to later apply it on.
  1670. .sp
  1671. Note that \fBsqlmigrate\fP doesn\(aqt colorize its output.
  1672. .INDENT 0.0
  1673. .TP
  1674. .B \-\-backwards
  1675. .UNINDENT
  1676. .sp
  1677. Generates the SQL for unapplying the migration. By default, the SQL created is
  1678. for running the migration in the forwards direction.
  1679. .INDENT 0.0
  1680. .TP
  1681. .B \-\-database DATABASE
  1682. .UNINDENT
  1683. .sp
  1684. Specifies the database for which to generate the SQL. Defaults to \fBdefault\fP\&.
  1685. .SS \fBsqlsequencereset\fP
  1686. .INDENT 0.0
  1687. .TP
  1688. .B django\-admin sqlsequencereset app_label [app_label ...]
  1689. .UNINDENT
  1690. .sp
  1691. Prints the SQL statements for resetting sequences for the given app name(s).
  1692. .sp
  1693. Sequences are indexes used by some database engines to track the next available
  1694. number for automatically incremented fields.
  1695. .sp
  1696. Use this command to generate SQL which will fix cases where a sequence is out
  1697. of sync with its automatically incremented field data.
  1698. .INDENT 0.0
  1699. .TP
  1700. .B \-\-database DATABASE
  1701. .UNINDENT
  1702. .sp
  1703. Specifies the database for which to print the SQL. Defaults to \fBdefault\fP\&.
  1704. .SS \fBsquashmigrations\fP
  1705. .INDENT 0.0
  1706. .TP
  1707. .B django\-admin squashmigrations app_label [start_migration_name] migration_name
  1708. .UNINDENT
  1709. .sp
  1710. Squashes the migrations for \fBapp_label\fP up to and including \fBmigration_name\fP
  1711. down into fewer migrations, if possible. The resulting squashed migrations
  1712. can live alongside the unsquashed ones safely. For more information,
  1713. please read migration\-squashing\&.
  1714. .sp
  1715. When \fBstart_migration_name\fP is given, Django will only include migrations
  1716. starting from and including this migration. This helps to mitigate the
  1717. squashing limitation of \fBRunPython\fP and
  1718. \fBdjango.db.migrations.operations.RunSQL\fP migration operations.
  1719. .INDENT 0.0
  1720. .TP
  1721. .B \-\-no\-optimize
  1722. .UNINDENT
  1723. .sp
  1724. Disables the optimizer when generating a squashed migration. By default, Django
  1725. will try to optimize the operations in your migrations to reduce the size of
  1726. the resulting file. Use this option if this process is failing or creating
  1727. incorrect migrations, though please also file a Django bug report about the
  1728. behavior, as optimization is meant to be safe.
  1729. .INDENT 0.0
  1730. .TP
  1731. .B \-\-noinput, \-\-no\-input
  1732. .UNINDENT
  1733. .sp
  1734. Suppresses all user prompts.
  1735. .INDENT 0.0
  1736. .TP
  1737. .B \-\-squashed\-name SQUASHED_NAME
  1738. .UNINDENT
  1739. .sp
  1740. Sets the name of the squashed migration. When omitted, the name is based on the
  1741. first and last migration, with \fB_squashed_\fP in between.
  1742. .INDENT 0.0
  1743. .TP
  1744. .B \-\-no\-header
  1745. .UNINDENT
  1746. .sp
  1747. Generate squashed migration file without Django version and timestamp header.
  1748. .SS \fBstartapp\fP
  1749. .INDENT 0.0
  1750. .TP
  1751. .B django\-admin startapp name [directory]
  1752. .UNINDENT
  1753. .sp
  1754. Creates a Django app directory structure for the given app name in the current
  1755. directory or the given destination.
  1756. .sp
  1757. By default, \fI\%the new directory\fP contains a
  1758. \fBmodels.py\fP file and other app template files. If only the app name is given,
  1759. the app directory will be created in the current working directory.
  1760. .sp
  1761. If the optional destination is provided, Django will use that existing
  1762. directory rather than creating a new one. You can use \(aq.\(aq to denote the current
  1763. working directory.
  1764. .sp
  1765. For example:
  1766. .INDENT 0.0
  1767. .INDENT 3.5
  1768. .sp
  1769. .nf
  1770. .ft C
  1771. django\-admin startapp myapp /Users/jezdez/Code/myapp
  1772. .ft P
  1773. .fi
  1774. .UNINDENT
  1775. .UNINDENT
  1776. .INDENT 0.0
  1777. .TP
  1778. .B \-\-template TEMPLATE
  1779. .UNINDENT
  1780. .sp
  1781. Provides the path to a directory with a custom app template file, or a path to
  1782. an uncompressed archive (\fB\&.tar\fP) or a compressed archive (\fB\&.tar.gz\fP,
  1783. \fB\&.tar.bz2\fP, \fB\&.tar.xz\fP, \fB\&.tar.lzma\fP, \fB\&.tgz\fP, \fB\&.tbz2\fP, \fB\&.txz\fP,
  1784. \fB\&.tlz\fP, \fB\&.zip\fP) containing the app template files.
  1785. .sp
  1786. For example, this would look for an app template in the given directory when
  1787. creating the \fBmyapp\fP app:
  1788. .INDENT 0.0
  1789. .INDENT 3.5
  1790. .sp
  1791. .nf
  1792. .ft C
  1793. django\-admin startapp \-\-template=/Users/jezdez/Code/my_app_template myapp
  1794. .ft P
  1795. .fi
  1796. .UNINDENT
  1797. .UNINDENT
  1798. .sp
  1799. Django will also accept URLs (\fBhttp\fP, \fBhttps\fP, \fBftp\fP) to compressed
  1800. archives with the app template files, downloading and extracting them on the
  1801. fly.
  1802. .sp
  1803. For example, taking advantage of GitHub\(aqs feature to expose repositories as
  1804. zip files, you can use a URL like:
  1805. .INDENT 0.0
  1806. .INDENT 3.5
  1807. .sp
  1808. .nf
  1809. .ft C
  1810. django\-admin startapp \-\-template=https://github.com/githubuser/django\-app\-template/archive/main.zip myapp
  1811. .ft P
  1812. .fi
  1813. .UNINDENT
  1814. .UNINDENT
  1815. .INDENT 0.0
  1816. .TP
  1817. .B \-\-extension EXTENSIONS, \-e EXTENSIONS
  1818. .UNINDENT
  1819. .sp
  1820. Specifies which file extensions in the app template should be rendered with the
  1821. template engine. Defaults to \fBpy\fP\&.
  1822. .INDENT 0.0
  1823. .TP
  1824. .B \-\-name FILES, \-n FILES
  1825. .UNINDENT
  1826. .sp
  1827. Specifies which files in the app template (in addition to those matching
  1828. \fB\-\-extension\fP) should be rendered with the template engine. Defaults to an
  1829. empty list.
  1830. .INDENT 0.0
  1831. .TP
  1832. .B \-\-exclude DIRECTORIES, \-x DIRECTORIES
  1833. .UNINDENT
  1834. .sp
  1835. .sp
  1836. Specifies which directories in the app template should be excluded, in addition
  1837. to \fB\&.git\fP and \fB__pycache__\fP\&. If this option is not provided, directories
  1838. named \fB__pycache__\fP or starting with \fB\&.\fP will be excluded.
  1839. .sp
  1840. The \fBtemplate context\fP used for all matching
  1841. files is:
  1842. .INDENT 0.0
  1843. .IP \(bu 2
  1844. Any option passed to the \fBstartapp\fP command (among the command\(aqs supported
  1845. options)
  1846. .IP \(bu 2
  1847. \fBapp_name\fP \-\- the app name as passed to the command
  1848. .IP \(bu 2
  1849. \fBapp_directory\fP \-\- the full path of the newly created app
  1850. .IP \(bu 2
  1851. \fBcamel_case_app_name\fP \-\- the app name in camel case format
  1852. .IP \(bu 2
  1853. \fBdocs_version\fP \-\- the version of the documentation: \fB\(aqdev\(aq\fP or \fB\(aq1.x\(aq\fP
  1854. .IP \(bu 2
  1855. \fBdjango_version\fP \-\- the version of Django, e.g. \fB\(aq2.0.3\(aq\fP
  1856. .UNINDENT
  1857. .sp
  1858. \fBWARNING:\fP
  1859. .INDENT 0.0
  1860. .INDENT 3.5
  1861. When the app template files are rendered with the Django template
  1862. engine (by default all \fB*.py\fP files), Django will also replace all
  1863. stray template variables contained. For example, if one of the Python files
  1864. contains a docstring explaining a particular feature related
  1865. to template rendering, it might result in an incorrect example.
  1866. .sp
  1867. To work around this problem, you can use the \fBtemplatetag\fP
  1868. template tag to "escape" the various parts of the template syntax.
  1869. .sp
  1870. In addition, to allow Python template files that contain Django template
  1871. language syntax while also preventing packaging systems from trying to
  1872. byte\-compile invalid \fB*.py\fP files, template files ending with \fB\&.py\-tpl\fP
  1873. will be renamed to \fB\&.py\fP\&.
  1874. .UNINDENT
  1875. .UNINDENT
  1876. .SS \fBstartproject\fP
  1877. .INDENT 0.0
  1878. .TP
  1879. .B django\-admin startproject name [directory]
  1880. .UNINDENT
  1881. .sp
  1882. Creates a Django project directory structure for the given project name in
  1883. the current directory or the given destination.
  1884. .sp
  1885. By default, \fI\%the new directory\fP contains
  1886. \fBmanage.py\fP and a project package (containing a \fBsettings.py\fP and other
  1887. files).
  1888. .sp
  1889. If only the project name is given, both the project directory and project
  1890. package will be named \fB<projectname>\fP and the project directory
  1891. will be created in the current working directory.
  1892. .sp
  1893. If the optional destination is provided, Django will use that existing
  1894. directory as the project directory, and create \fBmanage.py\fP and the project
  1895. package within it. Use \(aq.\(aq to denote the current working directory.
  1896. .sp
  1897. For example:
  1898. .INDENT 0.0
  1899. .INDENT 3.5
  1900. .sp
  1901. .nf
  1902. .ft C
  1903. django\-admin startproject myproject /Users/jezdez/Code/myproject_repo
  1904. .ft P
  1905. .fi
  1906. .UNINDENT
  1907. .UNINDENT
  1908. .INDENT 0.0
  1909. .TP
  1910. .B \-\-template TEMPLATE
  1911. .UNINDENT
  1912. .sp
  1913. Specifies a directory, file path, or URL of a custom project template. See the
  1914. \fI\%startapp \-\-template\fP documentation for examples and usage.
  1915. .INDENT 0.0
  1916. .TP
  1917. .B \-\-extension EXTENSIONS, \-e EXTENSIONS
  1918. .UNINDENT
  1919. .sp
  1920. Specifies which file extensions in the project template should be rendered with
  1921. the template engine. Defaults to \fBpy\fP\&.
  1922. .INDENT 0.0
  1923. .TP
  1924. .B \-\-name FILES, \-n FILES
  1925. .UNINDENT
  1926. .sp
  1927. Specifies which files in the project template (in addition to those matching
  1928. \fB\-\-extension\fP) should be rendered with the template engine. Defaults to an
  1929. empty list.
  1930. .INDENT 0.0
  1931. .TP
  1932. .B \-\-exclude DIRECTORIES, \-x DIRECTORIES
  1933. .UNINDENT
  1934. .sp
  1935. .sp
  1936. Specifies which directories in the project template should be excluded, in
  1937. addition to \fB\&.git\fP and \fB__pycache__\fP\&. If this option is not provided,
  1938. directories named \fB__pycache__\fP or starting with \fB\&.\fP will be excluded.
  1939. .sp
  1940. The \fBtemplate context\fP used is:
  1941. .INDENT 0.0
  1942. .IP \(bu 2
  1943. Any option passed to the \fBstartproject\fP command (among the command\(aqs
  1944. supported options)
  1945. .IP \(bu 2
  1946. \fBproject_name\fP \-\- the project name as passed to the command
  1947. .IP \(bu 2
  1948. \fBproject_directory\fP \-\- the full path of the newly created project
  1949. .IP \(bu 2
  1950. \fBsecret_key\fP \-\- a random key for the \fBSECRET_KEY\fP setting
  1951. .IP \(bu 2
  1952. \fBdocs_version\fP \-\- the version of the documentation: \fB\(aqdev\(aq\fP or \fB\(aq1.x\(aq\fP
  1953. .IP \(bu 2
  1954. \fBdjango_version\fP \-\- the version of Django, e.g. \fB\(aq2.0.3\(aq\fP
  1955. .UNINDENT
  1956. .sp
  1957. Please also see the \fI\%rendering warning\fP as mentioned
  1958. for \fI\%startapp\fP\&.
  1959. .SS \fBtest\fP
  1960. .INDENT 0.0
  1961. .TP
  1962. .B django\-admin test [test_label [test_label ...]]
  1963. .UNINDENT
  1964. .sp
  1965. Runs tests for all installed apps. See /topics/testing/index for more
  1966. information.
  1967. .INDENT 0.0
  1968. .TP
  1969. .B \-\-failfast
  1970. .UNINDENT
  1971. .sp
  1972. Stops running tests and reports the failure immediately after a test fails.
  1973. .INDENT 0.0
  1974. .TP
  1975. .B \-\-testrunner TESTRUNNER
  1976. .UNINDENT
  1977. .sp
  1978. Controls the test runner class that is used to execute tests. This value
  1979. overrides the value provided by the \fBTEST_RUNNER\fP setting.
  1980. .INDENT 0.0
  1981. .TP
  1982. .B \-\-noinput, \-\-no\-input
  1983. .UNINDENT
  1984. .sp
  1985. Suppresses all user prompts. A typical prompt is a warning about deleting an
  1986. existing test database.
  1987. .SS Test runner options
  1988. .sp
  1989. The \fBtest\fP command receives options on behalf of the specified
  1990. \fI\%\-\-testrunner\fP\&. These are the options of the default test runner:
  1991. \fBDiscoverRunner\fP\&.
  1992. .INDENT 0.0
  1993. .TP
  1994. .B \-\-keepdb
  1995. .UNINDENT
  1996. .sp
  1997. Preserves the test database between test runs. This has the advantage of
  1998. skipping both the create and destroy actions which can greatly decrease the
  1999. time to run tests, especially those in a large test suite. If the test database
  2000. does not exist, it will be created on the first run and then preserved for each
  2001. subsequent run. Unless the \fBMIGRATE\fP test setting is
  2002. \fBFalse\fP, any unapplied migrations will also be applied to the test database
  2003. before running the test suite.
  2004. .INDENT 0.0
  2005. .TP
  2006. .B \-\-shuffle [SEED]
  2007. .UNINDENT
  2008. .sp
  2009. .sp
  2010. Randomizes the order of tests before running them. This can help detect tests
  2011. that aren\(aqt properly isolated. The test order generated by this option is a
  2012. deterministic function of the integer seed given. When no seed is passed, a
  2013. seed is chosen randomly and printed to the console. To repeat a particular test
  2014. order, pass a seed. The test orders generated by this option preserve Django\(aqs
  2015. guarantees on test order\&. They also keep tests grouped
  2016. by test case class.
  2017. .sp
  2018. The shuffled orderings also have a special consistency property useful when
  2019. narrowing down isolation issues. Namely, for a given seed and when running a
  2020. subset of tests, the new order will be the original shuffling restricted to the
  2021. smaller set. Similarly, when adding tests while keeping the seed the same, the
  2022. order of the original tests will be the same in the new order.
  2023. .INDENT 0.0
  2024. .TP
  2025. .B \-\-reverse, \-r
  2026. .UNINDENT
  2027. .sp
  2028. Sorts test cases in the opposite execution order. This may help in debugging
  2029. the side effects of tests that aren\(aqt properly isolated. Grouping by test
  2030. class is preserved when using this option. This can be used
  2031. in conjunction with \fB\-\-shuffle\fP to reverse the order for a particular seed.
  2032. .INDENT 0.0
  2033. .TP
  2034. .B \-\-debug\-mode
  2035. .UNINDENT
  2036. .sp
  2037. Sets the \fBDEBUG\fP setting to \fBTrue\fP prior to running tests. This may
  2038. help troubleshoot test failures.
  2039. .INDENT 0.0
  2040. .TP
  2041. .B \-\-debug\-sql, \-d
  2042. .UNINDENT
  2043. .sp
  2044. Enables SQL logging for failing tests. If
  2045. \fB\-\-verbosity\fP is \fB2\fP, then queries in passing tests are also output.
  2046. .INDENT 0.0
  2047. .TP
  2048. .B \-\-parallel [N]
  2049. .UNINDENT
  2050. .INDENT 0.0
  2051. .TP
  2052. .B DJANGO_TEST_PROCESSES
  2053. .UNINDENT
  2054. .sp
  2055. Runs tests in separate parallel processes. Since modern processors have
  2056. multiple cores, this allows running tests significantly faster.
  2057. .sp
  2058. Using \fB\-\-parallel\fP without a value, or with the value \fBauto\fP, runs one test
  2059. process per core according to \fI\%multiprocessing.cpu_count()\fP\&. You can
  2060. override this by passing the desired number of processes, e.g.
  2061. \fB\-\-parallel 4\fP, or by setting the \fI\%DJANGO_TEST_PROCESSES\fP environment
  2062. variable.
  2063. .sp
  2064. Django distributes test cases — \fI\%unittest.TestCase\fP subclasses — to
  2065. subprocesses. If there are fewer test cases than configured processes, Django
  2066. will reduce the number of processes accordingly.
  2067. .sp
  2068. Each process gets its own database. You must ensure that different test cases
  2069. don\(aqt access the same resources. For instance, test cases that touch the
  2070. filesystem should create a temporary directory for their own use.
  2071. .sp
  2072. \fBNOTE:\fP
  2073. .INDENT 0.0
  2074. .INDENT 3.5
  2075. If you have test classes that cannot be run in parallel, you can use
  2076. \fBSerializeMixin\fP to run them sequentially. See Enforce running test
  2077. classes sequentially\&.
  2078. .UNINDENT
  2079. .UNINDENT
  2080. .sp
  2081. This option requires the third\-party \fBtblib\fP package to display tracebacks
  2082. correctly:
  2083. .INDENT 0.0
  2084. .INDENT 3.5
  2085. .sp
  2086. .nf
  2087. .ft C
  2088. $ python \-m pip install tblib
  2089. .ft P
  2090. .fi
  2091. .UNINDENT
  2092. .UNINDENT
  2093. .sp
  2094. This feature isn\(aqt available on Windows. It doesn\(aqt work with the Oracle
  2095. database backend either.
  2096. .sp
  2097. If you want to use \fI\%pdb\fP while debugging tests, you must disable parallel
  2098. execution (\fB\-\-parallel=1\fP). You\(aqll see something like \fBbdb.BdbQuit\fP if you
  2099. don\(aqt.
  2100. .sp
  2101. \fBWARNING:\fP
  2102. .INDENT 0.0
  2103. .INDENT 3.5
  2104. When test parallelization is enabled and a test fails, Django may be
  2105. unable to display the exception traceback. This can make debugging
  2106. difficult. If you encounter this problem, run the affected test without
  2107. parallelization to see the traceback of the failure.
  2108. .sp
  2109. This is a known limitation. It arises from the need to serialize objects
  2110. in order to exchange them between processes. See
  2111. \fI\%What can be pickled and unpickled?\fP for details.
  2112. .UNINDENT
  2113. .UNINDENT
  2114. .sp
  2115. Support for the value \fBauto\fP was added.
  2116. .INDENT 0.0
  2117. .TP
  2118. .B \-\-tag TAGS
  2119. .UNINDENT
  2120. .sp
  2121. Runs only tests marked with the specified tags\&.
  2122. May be specified multiple times and combined with \fI\%test \-\-exclude\-tag\fP\&.
  2123. .sp
  2124. Tests that fail to load are always considered matching.
  2125. .sp
  2126. In older versions, tests that failed to load did not match tags.
  2127. .INDENT 0.0
  2128. .TP
  2129. .B \-\-exclude\-tag EXCLUDE_TAGS
  2130. .UNINDENT
  2131. .sp
  2132. Excludes tests marked with the specified tags\&.
  2133. May be specified multiple times and combined with \fI\%test \-\-tag\fP\&.
  2134. .INDENT 0.0
  2135. .TP
  2136. .B \-k TEST_NAME_PATTERNS
  2137. .UNINDENT
  2138. .sp
  2139. Runs test methods and classes matching test name patterns, in the same way as
  2140. \fI\%unittest\(aqs \-k option\fP\&. Can be specified multiple times.
  2141. .INDENT 0.0
  2142. .TP
  2143. .B \-\-pdb
  2144. .UNINDENT
  2145. .sp
  2146. Spawns a \fBpdb\fP debugger at each test error or failure. If you have it
  2147. installed, \fBipdb\fP is used instead.
  2148. .INDENT 0.0
  2149. .TP
  2150. .B \-\-buffer, \-b
  2151. .UNINDENT
  2152. .sp
  2153. Discards output (\fBstdout\fP and \fBstderr\fP) for passing tests, in the same way
  2154. as \fI\%unittest\(aqs \-\-buffer option\fP\&.
  2155. .INDENT 0.0
  2156. .TP
  2157. .B \-\-no\-faulthandler
  2158. .UNINDENT
  2159. .sp
  2160. .sp
  2161. Django automatically calls \fI\%faulthandler.enable()\fP when starting the
  2162. tests, which allows it to print a traceback if the interpreter crashes. Pass
  2163. \fB\-\-no\-faulthandler\fP to disable this behavior.
  2164. .INDENT 0.0
  2165. .TP
  2166. .B \-\-timing
  2167. .UNINDENT
  2168. .sp
  2169. .sp
  2170. Outputs timings, including database setup and total run time.
  2171. .SS \fBtestserver\fP
  2172. .INDENT 0.0
  2173. .TP
  2174. .B django\-admin testserver [fixture [fixture ...]]
  2175. .UNINDENT
  2176. .sp
  2177. Runs a Django development server (as in \fI\%runserver\fP) using data from
  2178. the given fixture(s).
  2179. .sp
  2180. For example, this command:
  2181. .INDENT 0.0
  2182. .INDENT 3.5
  2183. .sp
  2184. .nf
  2185. .ft C
  2186. django\-admin testserver mydata.json
  2187. .ft P
  2188. .fi
  2189. .UNINDENT
  2190. .UNINDENT
  2191. .sp
  2192. \&...would perform the following steps:
  2193. .INDENT 0.0
  2194. .IP 1. 3
  2195. Create a test database, as described in the\-test\-database\&.
  2196. .IP 2. 3
  2197. Populate the test database with fixture data from the given fixtures.
  2198. (For more on fixtures, see the documentation for \fI\%loaddata\fP above.)
  2199. .IP 3. 3
  2200. Runs the Django development server (as in \fI\%runserver\fP), pointed at
  2201. this newly created test database instead of your production database.
  2202. .UNINDENT
  2203. .sp
  2204. This is useful in a number of ways:
  2205. .INDENT 0.0
  2206. .IP \(bu 2
  2207. When you\(aqre writing unit tests of how your views
  2208. act with certain fixture data, you can use \fBtestserver\fP to interact with
  2209. the views in a web browser, manually.
  2210. .IP \(bu 2
  2211. Let\(aqs say you\(aqre developing your Django application and have a "pristine"
  2212. copy of a database that you\(aqd like to interact with. You can dump your
  2213. database to a fixture (using the \fI\%dumpdata\fP command, explained
  2214. above), then use \fBtestserver\fP to run your web application with that data.
  2215. With this arrangement, you have the flexibility of messing up your data
  2216. in any way, knowing that whatever data changes you\(aqre making are only
  2217. being made to a test database.
  2218. .UNINDENT
  2219. .sp
  2220. Note that this server does \fInot\fP automatically detect changes to your Python
  2221. source code (as \fI\%runserver\fP does). It does, however, detect changes to
  2222. templates.
  2223. .INDENT 0.0
  2224. .TP
  2225. .B \-\-addrport ADDRPORT
  2226. .UNINDENT
  2227. .sp
  2228. Specifies a different port, or IP address and port, from the default of
  2229. \fB127.0.0.1:8000\fP\&. This value follows exactly the same format and serves
  2230. exactly the same function as the argument to the \fI\%runserver\fP command.
  2231. .sp
  2232. Examples:
  2233. .sp
  2234. To run the test server on port 7000 with \fBfixture1\fP and \fBfixture2\fP:
  2235. .INDENT 0.0
  2236. .INDENT 3.5
  2237. .sp
  2238. .nf
  2239. .ft C
  2240. django\-admin testserver \-\-addrport 7000 fixture1 fixture2
  2241. django\-admin testserver fixture1 fixture2 \-\-addrport 7000
  2242. .ft P
  2243. .fi
  2244. .UNINDENT
  2245. .UNINDENT
  2246. .sp
  2247. (The above statements are equivalent. We include both of them to demonstrate
  2248. that it doesn\(aqt matter whether the options come before or after the fixture
  2249. arguments.)
  2250. .sp
  2251. To run on 1.2.3.4:7000 with a \fBtest\fP fixture:
  2252. .INDENT 0.0
  2253. .INDENT 3.5
  2254. .sp
  2255. .nf
  2256. .ft C
  2257. django\-admin testserver \-\-addrport 1.2.3.4:7000 test
  2258. .ft P
  2259. .fi
  2260. .UNINDENT
  2261. .UNINDENT
  2262. .INDENT 0.0
  2263. .TP
  2264. .B \-\-noinput, \-\-no\-input
  2265. .UNINDENT
  2266. .sp
  2267. Suppresses all user prompts. A typical prompt is a warning about deleting an
  2268. existing test database.
  2269. .SH COMMANDS PROVIDED BY APPLICATIONS
  2270. .sp
  2271. Some commands are only available when the \fBdjango.contrib\fP application that
  2272. implements them has been
  2273. \fBenabled\fP\&. This section describes them grouped by
  2274. their application.
  2275. .SS \fBdjango.contrib.auth\fP
  2276. .SS \fBchangepassword\fP
  2277. .INDENT 0.0
  2278. .TP
  2279. .B django\-admin changepassword [<username>]
  2280. .UNINDENT
  2281. .sp
  2282. This command is only available if Django\(aqs authentication system (\fBdjango.contrib.auth\fP) is installed.
  2283. .sp
  2284. Allows changing a user\(aqs password. It prompts you to enter a new password twice
  2285. for the given user. If the entries are identical, this immediately becomes the
  2286. new password. If you do not supply a user, the command will attempt to change
  2287. the password whose username matches the current user.
  2288. .INDENT 0.0
  2289. .TP
  2290. .B \-\-database DATABASE
  2291. .UNINDENT
  2292. .sp
  2293. Specifies the database to query for the user. Defaults to \fBdefault\fP\&.
  2294. .sp
  2295. Example usage:
  2296. .INDENT 0.0
  2297. .INDENT 3.5
  2298. .sp
  2299. .nf
  2300. .ft C
  2301. django\-admin changepassword ringo
  2302. .ft P
  2303. .fi
  2304. .UNINDENT
  2305. .UNINDENT
  2306. .SS \fBcreatesuperuser\fP
  2307. .INDENT 0.0
  2308. .TP
  2309. .B django\-admin createsuperuser
  2310. .UNINDENT
  2311. .INDENT 0.0
  2312. .TP
  2313. .B DJANGO_SUPERUSER_PASSWORD
  2314. .UNINDENT
  2315. .sp
  2316. This command is only available if Django\(aqs authentication system (\fBdjango.contrib.auth\fP) is installed.
  2317. .sp
  2318. Creates a superuser account (a user who has all permissions). This is
  2319. useful if you need to create an initial superuser account or if you need to
  2320. programmatically generate superuser accounts for your site(s).
  2321. .sp
  2322. When run interactively, this command will prompt for a password for
  2323. the new superuser account. When run non\-interactively, you can provide
  2324. a password by setting the \fI\%DJANGO_SUPERUSER_PASSWORD\fP environment
  2325. variable. Otherwise, no password will be set, and the superuser account will
  2326. not be able to log in until a password has been manually set for it.
  2327. .sp
  2328. In non\-interactive mode, the
  2329. \fBUSERNAME_FIELD\fP and required
  2330. fields (listed in
  2331. \fBREQUIRED_FIELDS\fP) fall back to
  2332. \fBDJANGO_SUPERUSER_<uppercase_field_name>\fP environment variables, unless they
  2333. are overridden by a command line argument. For example, to provide an \fBemail\fP
  2334. field, you can use \fBDJANGO_SUPERUSER_EMAIL\fP environment variable.
  2335. .INDENT 0.0
  2336. .TP
  2337. .B \-\-noinput, \-\-no\-input
  2338. .UNINDENT
  2339. .sp
  2340. Suppresses all user prompts. If a suppressed prompt cannot be resolved
  2341. automatically, the command will exit with error code 1.
  2342. .INDENT 0.0
  2343. .TP
  2344. .B \-\-username USERNAME
  2345. .UNINDENT
  2346. .INDENT 0.0
  2347. .TP
  2348. .B \-\-email EMAIL
  2349. .UNINDENT
  2350. .sp
  2351. The username and email address for the new account can be supplied by
  2352. using the \fB\-\-username\fP and \fB\-\-email\fP arguments on the command
  2353. line. If either of those is not supplied, \fBcreatesuperuser\fP will prompt for
  2354. it when running interactively.
  2355. .INDENT 0.0
  2356. .TP
  2357. .B \-\-database DATABASE
  2358. .UNINDENT
  2359. .sp
  2360. Specifies the database into which the superuser object will be saved.
  2361. .sp
  2362. You can subclass the management command and override \fBget_input_data()\fP if you
  2363. want to customize data input and validation. Consult the source code for
  2364. details on the existing implementation and the method\(aqs parameters. For example,
  2365. it could be useful if you have a \fBForeignKey\fP in
  2366. \fBREQUIRED_FIELDS\fP and want to
  2367. allow creating an instance instead of entering the primary key of an existing
  2368. instance.
  2369. .SS \fBdjango.contrib.contenttypes\fP
  2370. .SS \fBremove_stale_contenttypes\fP
  2371. .INDENT 0.0
  2372. .TP
  2373. .B django\-admin remove_stale_contenttypes
  2374. .UNINDENT
  2375. .sp
  2376. This command is only available if Django\(aqs contenttypes app (\fBdjango.contrib.contenttypes\fP) is installed.
  2377. .sp
  2378. Deletes stale content types (from deleted models) in your database. Any objects
  2379. that depend on the deleted content types will also be deleted. A list of
  2380. deleted objects will be displayed before you confirm it\(aqs okay to proceed with
  2381. the deletion.
  2382. .INDENT 0.0
  2383. .TP
  2384. .B \-\-database DATABASE
  2385. .UNINDENT
  2386. .sp
  2387. Specifies the database to use. Defaults to \fBdefault\fP\&.
  2388. .INDENT 0.0
  2389. .TP
  2390. .B \-\-include\-stale\-apps
  2391. .UNINDENT
  2392. .sp
  2393. Deletes stale content types including ones from previously installed apps that
  2394. have been removed from \fBINSTALLED_APPS\fP\&. Defaults to \fBFalse\fP\&.
  2395. .SS \fBdjango.contrib.gis\fP
  2396. .SS \fBogrinspect\fP
  2397. .sp
  2398. This command is only available if GeoDjango
  2399. (\fBdjango.contrib.gis\fP) is installed.
  2400. .sp
  2401. Please refer to its \fBdescription\fP in the GeoDjango
  2402. documentation.
  2403. .SS \fBdjango.contrib.sessions\fP
  2404. .SS \fBclearsessions\fP
  2405. .INDENT 0.0
  2406. .TP
  2407. .B django\-admin clearsessions
  2408. .UNINDENT
  2409. .sp
  2410. Can be run as a cron job or directly to clean out expired sessions.
  2411. .SS \fBdjango.contrib.sitemaps\fP
  2412. .SS \fBping_google\fP
  2413. .sp
  2414. This command is only available if the Sitemaps framework (\fBdjango.contrib.sitemaps\fP) is installed.
  2415. .sp
  2416. Please refer to its \fBdescription\fP in the Sitemaps
  2417. documentation.
  2418. .SS \fBdjango.contrib.staticfiles\fP
  2419. .SS \fBcollectstatic\fP
  2420. .sp
  2421. This command is only available if the static files application (\fBdjango.contrib.staticfiles\fP) is installed.
  2422. .sp
  2423. Please refer to its \fBdescription\fP in the
  2424. staticfiles documentation.
  2425. .SS \fBfindstatic\fP
  2426. .sp
  2427. This command is only available if the static files application (\fBdjango.contrib.staticfiles\fP) is installed.
  2428. .sp
  2429. Please refer to its \fBdescription\fP in the staticfiles documentation.
  2430. .SH DEFAULT OPTIONS
  2431. .sp
  2432. Although some commands may allow their own custom options, every command
  2433. allows for the following options by default:
  2434. .INDENT 0.0
  2435. .TP
  2436. .B \-\-pythonpath PYTHONPATH
  2437. .UNINDENT
  2438. .sp
  2439. Adds the given filesystem path to the Python \fI\%import search path\fP\&. If this
  2440. isn\(aqt provided, \fBdjango\-admin\fP will use the \fI\%PYTHONPATH\fP environment
  2441. variable.
  2442. .sp
  2443. This option is unnecessary in \fBmanage.py\fP, because it takes care of setting
  2444. the Python path for you.
  2445. .sp
  2446. Example usage:
  2447. .INDENT 0.0
  2448. .INDENT 3.5
  2449. .sp
  2450. .nf
  2451. .ft C
  2452. django\-admin migrate \-\-pythonpath=\(aq/home/djangoprojects/myproject\(aq
  2453. .ft P
  2454. .fi
  2455. .UNINDENT
  2456. .UNINDENT
  2457. .INDENT 0.0
  2458. .TP
  2459. .B \-\-settings SETTINGS
  2460. .UNINDENT
  2461. .sp
  2462. Specifies the settings module to use. The settings module should be in Python
  2463. package syntax, e.g. \fBmysite.settings\fP\&. If this isn\(aqt provided,
  2464. \fBdjango\-admin\fP will use the \fBDJANGO_SETTINGS_MODULE\fP environment
  2465. variable.
  2466. .sp
  2467. This option is unnecessary in \fBmanage.py\fP, because it uses
  2468. \fBsettings.py\fP from the current project by default.
  2469. .sp
  2470. Example usage:
  2471. .INDENT 0.0
  2472. .INDENT 3.5
  2473. .sp
  2474. .nf
  2475. .ft C
  2476. django\-admin migrate \-\-settings=mysite.settings
  2477. .ft P
  2478. .fi
  2479. .UNINDENT
  2480. .UNINDENT
  2481. .INDENT 0.0
  2482. .TP
  2483. .B \-\-traceback
  2484. .UNINDENT
  2485. .sp
  2486. Displays a full stack trace when a \fBCommandError\fP
  2487. is raised. By default, \fBdjango\-admin\fP will show an error message when a
  2488. \fBCommandError\fP occurs and a full stack trace for any other exception.
  2489. .sp
  2490. This option is ignored by \fI\%runserver\fP\&.
  2491. .sp
  2492. Example usage:
  2493. .INDENT 0.0
  2494. .INDENT 3.5
  2495. .sp
  2496. .nf
  2497. .ft C
  2498. django\-admin migrate \-\-traceback
  2499. .ft P
  2500. .fi
  2501. .UNINDENT
  2502. .UNINDENT
  2503. .INDENT 0.0
  2504. .TP
  2505. .B \-\-verbosity {0,1,2,3}, \-v {0,1,2,3}
  2506. .UNINDENT
  2507. .sp
  2508. Specifies the amount of notification and debug information that a command
  2509. should print to the console.
  2510. .INDENT 0.0
  2511. .IP \(bu 2
  2512. \fB0\fP means no output.
  2513. .IP \(bu 2
  2514. \fB1\fP means normal output (default).
  2515. .IP \(bu 2
  2516. \fB2\fP means verbose output.
  2517. .IP \(bu 2
  2518. \fB3\fP means \fIvery\fP verbose output.
  2519. .UNINDENT
  2520. .sp
  2521. This option is ignored by \fI\%runserver\fP\&.
  2522. .sp
  2523. Example usage:
  2524. .INDENT 0.0
  2525. .INDENT 3.5
  2526. .sp
  2527. .nf
  2528. .ft C
  2529. django\-admin migrate \-\-verbosity 2
  2530. .ft P
  2531. .fi
  2532. .UNINDENT
  2533. .UNINDENT
  2534. .INDENT 0.0
  2535. .TP
  2536. .B \-\-no\-color
  2537. .UNINDENT
  2538. .sp
  2539. Disables colorized command output. Some commands format their output to be
  2540. colorized. For example, errors will be printed to the console in red and SQL
  2541. statements will be syntax highlighted.
  2542. .sp
  2543. Example usage:
  2544. .INDENT 0.0
  2545. .INDENT 3.5
  2546. .sp
  2547. .nf
  2548. .ft C
  2549. django\-admin runserver \-\-no\-color
  2550. .ft P
  2551. .fi
  2552. .UNINDENT
  2553. .UNINDENT
  2554. .INDENT 0.0
  2555. .TP
  2556. .B \-\-force\-color
  2557. .UNINDENT
  2558. .sp
  2559. Forces colorization of the command output if it would otherwise be disabled
  2560. as discussed in \fI\%Syntax coloring\fP\&. For example, you may want to pipe
  2561. colored output to another command.
  2562. .INDENT 0.0
  2563. .TP
  2564. .B \-\-skip\-checks
  2565. .UNINDENT
  2566. .sp
  2567. Skips running system checks prior to running the command. This option is only
  2568. available if the
  2569. \fBrequires_system_checks\fP command
  2570. attribute is not an empty list or tuple.
  2571. .sp
  2572. Example usage:
  2573. .INDENT 0.0
  2574. .INDENT 3.5
  2575. .sp
  2576. .nf
  2577. .ft C
  2578. django\-admin migrate \-\-skip\-checks
  2579. .ft P
  2580. .fi
  2581. .UNINDENT
  2582. .UNINDENT
  2583. .SH EXTRA NICETIES
  2584. .SS Syntax coloring
  2585. .INDENT 0.0
  2586. .TP
  2587. .B DJANGO_COLORS
  2588. .UNINDENT
  2589. .sp
  2590. The \fBdjango\-admin\fP / \fBmanage.py\fP commands will use pretty
  2591. color\-coded output if your terminal supports ANSI\-colored output. It
  2592. won\(aqt use the color codes if you\(aqre piping the command\(aqs output to
  2593. another program unless the \fI\%\-\-force\-color\fP option is used.
  2594. .SS Windows support
  2595. .sp
  2596. On Windows 10, the \fI\%Windows Terminal\fP application, \fI\%VS Code\fP, and PowerShell
  2597. (where virtual terminal processing is enabled) allow colored output, and are
  2598. supported by default.
  2599. .sp
  2600. Under Windows, the legacy \fBcmd.exe\fP native console doesn\(aqt support ANSI
  2601. escape sequences so by default there is no color output. In this case either of
  2602. two third\-party libraries are needed:
  2603. .INDENT 0.0
  2604. .IP \(bu 2
  2605. Install \fI\%colorama\fP, a Python package that translates ANSI color codes into
  2606. Windows API calls. Django commands will detect its presence and will make use
  2607. of its services to color output just like on Unix\-based platforms.
  2608. \fBcolorama\fP can be installed via pip:
  2609. .INDENT 2.0
  2610. .INDENT 3.5
  2611. .sp
  2612. .nf
  2613. .ft C
  2614. \&...\e> py \-m pip install colorama
  2615. .ft P
  2616. .fi
  2617. .UNINDENT
  2618. .UNINDENT
  2619. .IP \(bu 2
  2620. Install \fI\%ANSICON\fP, a third\-party tool that allows \fBcmd.exe\fP to process
  2621. ANSI color codes. Django commands will detect its presence and will make use
  2622. of its services to color output just like on Unix\-based platforms.
  2623. .UNINDENT
  2624. .sp
  2625. Other modern terminal environments on Windows, that support terminal colors,
  2626. but which are not automatically detected as supported by Django, may "fake" the
  2627. installation of \fBANSICON\fP by setting the appropriate environmental variable,
  2628. \fBANSICON="on"\fP\&.
  2629. .sp
  2630. Updated support for syntax coloring on Windows.
  2631. .SS Custom colors
  2632. .sp
  2633. The colors used for syntax highlighting can be customized. Django
  2634. ships with three color palettes:
  2635. .INDENT 0.0
  2636. .IP \(bu 2
  2637. \fBdark\fP, suited to terminals that show white text on a black
  2638. background. This is the default palette.
  2639. .IP \(bu 2
  2640. \fBlight\fP, suited to terminals that show black text on a white
  2641. background.
  2642. .IP \(bu 2
  2643. \fBnocolor\fP, which disables syntax highlighting.
  2644. .UNINDENT
  2645. .sp
  2646. You select a palette by setting a \fI\%DJANGO_COLORS\fP environment
  2647. variable to specify the palette you want to use. For example, to
  2648. specify the \fBlight\fP palette under a Unix or OS/X BASH shell, you
  2649. would run the following at a command prompt:
  2650. .INDENT 0.0
  2651. .INDENT 3.5
  2652. .sp
  2653. .nf
  2654. .ft C
  2655. export DJANGO_COLORS="light"
  2656. .ft P
  2657. .fi
  2658. .UNINDENT
  2659. .UNINDENT
  2660. .sp
  2661. You can also customize the colors that are used. Django specifies a
  2662. number of roles in which color is used:
  2663. .INDENT 0.0
  2664. .IP \(bu 2
  2665. \fBerror\fP \- A major error.
  2666. .IP \(bu 2
  2667. \fBnotice\fP \- A minor error.
  2668. .IP \(bu 2
  2669. \fBsuccess\fP \- A success.
  2670. .IP \(bu 2
  2671. \fBwarning\fP \- A warning.
  2672. .IP \(bu 2
  2673. \fBsql_field\fP \- The name of a model field in SQL.
  2674. .IP \(bu 2
  2675. \fBsql_coltype\fP \- The type of a model field in SQL.
  2676. .IP \(bu 2
  2677. \fBsql_keyword\fP \- An SQL keyword.
  2678. .IP \(bu 2
  2679. \fBsql_table\fP \- The name of a model in SQL.
  2680. .IP \(bu 2
  2681. \fBhttp_info\fP \- A 1XX HTTP Informational server response.
  2682. .IP \(bu 2
  2683. \fBhttp_success\fP \- A 2XX HTTP Success server response.
  2684. .IP \(bu 2
  2685. \fBhttp_not_modified\fP \- A 304 HTTP Not Modified server response.
  2686. .IP \(bu 2
  2687. \fBhttp_redirect\fP \- A 3XX HTTP Redirect server response other than 304.
  2688. .IP \(bu 2
  2689. \fBhttp_not_found\fP \- A 404 HTTP Not Found server response.
  2690. .IP \(bu 2
  2691. \fBhttp_bad_request\fP \- A 4XX HTTP Bad Request server response other than 404.
  2692. .IP \(bu 2
  2693. \fBhttp_server_error\fP \- A 5XX HTTP Server Error response.
  2694. .IP \(bu 2
  2695. \fBmigrate_heading\fP \- A heading in a migrations management command.
  2696. .IP \(bu 2
  2697. \fBmigrate_label\fP \- A migration name.
  2698. .UNINDENT
  2699. .sp
  2700. Each of these roles can be assigned a specific foreground and
  2701. background color, from the following list:
  2702. .INDENT 0.0
  2703. .IP \(bu 2
  2704. \fBblack\fP
  2705. .IP \(bu 2
  2706. \fBred\fP
  2707. .IP \(bu 2
  2708. \fBgreen\fP
  2709. .IP \(bu 2
  2710. \fByellow\fP
  2711. .IP \(bu 2
  2712. \fBblue\fP
  2713. .IP \(bu 2
  2714. \fBmagenta\fP
  2715. .IP \(bu 2
  2716. \fBcyan\fP
  2717. .IP \(bu 2
  2718. \fBwhite\fP
  2719. .UNINDENT
  2720. .sp
  2721. Each of these colors can then be modified by using the following
  2722. display options:
  2723. .INDENT 0.0
  2724. .IP \(bu 2
  2725. \fBbold\fP
  2726. .IP \(bu 2
  2727. \fBunderscore\fP
  2728. .IP \(bu 2
  2729. \fBblink\fP
  2730. .IP \(bu 2
  2731. \fBreverse\fP
  2732. .IP \(bu 2
  2733. \fBconceal\fP
  2734. .UNINDENT
  2735. .sp
  2736. A color specification follows one of the following patterns:
  2737. .INDENT 0.0
  2738. .IP \(bu 2
  2739. \fBrole=fg\fP
  2740. .IP \(bu 2
  2741. \fBrole=fg/bg\fP
  2742. .IP \(bu 2
  2743. \fBrole=fg,option,option\fP
  2744. .IP \(bu 2
  2745. \fBrole=fg/bg,option,option\fP
  2746. .UNINDENT
  2747. .sp
  2748. where \fBrole\fP is the name of a valid color role, \fBfg\fP is the
  2749. foreground color, \fBbg\fP is the background color and each \fBoption\fP
  2750. is one of the color modifying options. Multiple color specifications
  2751. are then separated by a semicolon. For example:
  2752. .INDENT 0.0
  2753. .INDENT 3.5
  2754. .sp
  2755. .nf
  2756. .ft C
  2757. export DJANGO_COLORS="error=yellow/blue,blink;notice=magenta"
  2758. .ft P
  2759. .fi
  2760. .UNINDENT
  2761. .UNINDENT
  2762. .sp
  2763. would specify that errors be displayed using blinking yellow on blue,
  2764. and notices displayed using magenta. All other color roles would be
  2765. left uncolored.
  2766. .sp
  2767. Colors can also be specified by extending a base palette. If you put
  2768. a palette name in a color specification, all the colors implied by that
  2769. palette will be loaded. So:
  2770. .INDENT 0.0
  2771. .INDENT 3.5
  2772. .sp
  2773. .nf
  2774. .ft C
  2775. export DJANGO_COLORS="light;error=yellow/blue,blink;notice=magenta"
  2776. .ft P
  2777. .fi
  2778. .UNINDENT
  2779. .UNINDENT
  2780. .sp
  2781. would specify the use of all the colors in the light color palette,
  2782. \fIexcept\fP for the colors for errors and notices which would be
  2783. overridden as specified.
  2784. .SS Bash completion
  2785. .sp
  2786. If you use the Bash shell, consider installing the Django bash completion
  2787. script, which lives in \fBextras/django_bash_completion\fP in the Django source
  2788. distribution. It enables tab\-completion of \fBdjango\-admin\fP and
  2789. \fBmanage.py\fP commands, so you can, for instance...
  2790. .INDENT 0.0
  2791. .IP \(bu 2
  2792. Type \fBdjango\-admin\fP\&.
  2793. .IP \(bu 2
  2794. Press [TAB] to see all available options.
  2795. .IP \(bu 2
  2796. Type \fBsql\fP, then [TAB], to see all available options whose names start
  2797. with \fBsql\fP\&.
  2798. .UNINDENT
  2799. .sp
  2800. See /howto/custom\-management\-commands for how to add customized actions.
  2801. .INDENT 0.0
  2802. .TP
  2803. .B django.core.management.call_command(name, *args, **options)
  2804. .UNINDENT
  2805. .sp
  2806. To call a management command from code use \fBcall_command\fP\&.
  2807. .INDENT 0.0
  2808. .TP
  2809. .B \fBname\fP
  2810. the name of the command to call or a command object. Passing the name is
  2811. preferred unless the object is required for testing.
  2812. .TP
  2813. .B \fB*args\fP
  2814. a list of arguments accepted by the command. Arguments are passed to the
  2815. argument parser, so you can use the same style as you would on the command
  2816. line. For example, \fBcall_command(\(aqflush\(aq, \(aq\-\-verbosity=0\(aq)\fP\&.
  2817. .TP
  2818. .B \fB**options\fP
  2819. named options accepted on the command\-line. Options are passed to the command
  2820. without triggering the argument parser, which means you\(aqll need to pass the
  2821. correct type. For example, \fBcall_command(\(aqflush\(aq, verbosity=0)\fP (zero must
  2822. be an integer rather than a string).
  2823. .UNINDENT
  2824. .sp
  2825. Examples:
  2826. .INDENT 0.0
  2827. .INDENT 3.5
  2828. .sp
  2829. .nf
  2830. .ft C
  2831. from django.core import management
  2832. from django.core.management.commands import loaddata
  2833. management.call_command(\(aqflush\(aq, verbosity=0, interactive=False)
  2834. management.call_command(\(aqloaddata\(aq, \(aqtest_data\(aq, verbosity=0)
  2835. management.call_command(loaddata.Command(), \(aqtest_data\(aq, verbosity=0)
  2836. .ft P
  2837. .fi
  2838. .UNINDENT
  2839. .UNINDENT
  2840. .sp
  2841. Note that command options that take no arguments are passed as keywords
  2842. with \fBTrue\fP or \fBFalse\fP, as you can see with the \fBinteractive\fP option above.
  2843. .sp
  2844. Named arguments can be passed by using either one of the following syntaxes:
  2845. .INDENT 0.0
  2846. .INDENT 3.5
  2847. .sp
  2848. .nf
  2849. .ft C
  2850. # Similar to the command line
  2851. management.call_command(\(aqdumpdata\(aq, \(aq\-\-natural\-foreign\(aq)
  2852. # Named argument similar to the command line minus the initial dashes and
  2853. # with internal dashes replaced by underscores
  2854. management.call_command(\(aqdumpdata\(aq, natural_foreign=True)
  2855. # \(gause_natural_foreign_keys\(ga is the option destination variable
  2856. management.call_command(\(aqdumpdata\(aq, use_natural_foreign_keys=True)
  2857. .ft P
  2858. .fi
  2859. .UNINDENT
  2860. .UNINDENT
  2861. .sp
  2862. Some command options have different names when using \fBcall_command()\fP instead
  2863. of \fBdjango\-admin\fP or \fBmanage.py\fP\&. For example, \fBdjango\-admin
  2864. createsuperuser \-\-no\-input\fP translates to \fBcall_command(\(aqcreatesuperuser\(aq,
  2865. interactive=False)\fP\&. To find what keyword argument name to use for
  2866. \fBcall_command()\fP, check the command\(aqs source code for the \fBdest\fP argument
  2867. passed to \fBparser.add_argument()\fP\&.
  2868. .sp
  2869. Command options which take multiple options are passed a list:
  2870. .INDENT 0.0
  2871. .INDENT 3.5
  2872. .sp
  2873. .nf
  2874. .ft C
  2875. management.call_command(\(aqdumpdata\(aq, exclude=[\(aqcontenttypes\(aq, \(aqauth\(aq])
  2876. .ft P
  2877. .fi
  2878. .UNINDENT
  2879. .UNINDENT
  2880. .sp
  2881. The return value of the \fBcall_command()\fP function is the same as the return
  2882. value of the \fBhandle()\fP method of the command.
  2883. .SH OUTPUT REDIRECTION
  2884. .sp
  2885. Note that you can redirect standard output and error streams as all commands
  2886. support the \fBstdout\fP and \fBstderr\fP options. For example, you could write:
  2887. .INDENT 0.0
  2888. .INDENT 3.5
  2889. .sp
  2890. .nf
  2891. .ft C
  2892. with open(\(aq/path/to/command_output\(aq, \(aqw\(aq) as f:
  2893. management.call_command(\(aqdumpdata\(aq, stdout=f)
  2894. .ft P
  2895. .fi
  2896. .UNINDENT
  2897. .UNINDENT
  2898. .SH AUTHOR
  2899. Django Software Foundation
  2900. .SH COPYRIGHT
  2901. Django Software Foundation and contributors
  2902. .\" Generated by docutils manpage writer.
  2903. .