django-admin.1 77 KB

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