django-admin.1 78 KB

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