django-admin.1 74 KB

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