django-admin.1 70 KB

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