django-admin.1 80 KB

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