django-admin.1 72 KB

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