django-admin.1 76 KB

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