Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 733 lines (506 sloc) 25.438 kB
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
1 ====================================
2 Appendix F: The django-admin Utility
3 ====================================
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
4
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
5 ``django-admin.py`` is Django's command-line utility for administrative tasks.
6 This appendix explains its many powers.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
7
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
8 You'll usually access ``django-admin.py`` through a project's ``manage.py``
9 wrapper. ``manage.py`` is automatically created in each Django project and is a
10 thin wrapper around ``django-admin.py``. It takes care of two things for you
11 before delegating to ``django-admin.py``:
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
12
fdc4800 @jacobian Fixed a bunch of reST markup errors.
jacobian authored
13 * It puts your project's package on ``sys.path``.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
14
fdc4800 @jacobian Fixed a bunch of reST markup errors.
jacobian authored
15 * It sets the ``DJANGO_SETTINGS_MODULE`` environment variable so that it
16 points to your project's ``settings.py`` file.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
17
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
18 The ``django-admin.py`` script should be on your system path if you installed
19 Django via its ``setup.py`` utility. If it's not on your path, you can find it in
20 ``site-packages/django/bin`` within your Python installation. Consider
21 symlinking it from some place on your path, such as ``/usr/local/bin``.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
22
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
23 Windows users, who do not have symlinking functionality available,
24 can copy ``django-admin.py`` to a location on their existing path or edit the
25 ``PATH`` settings (under Settings ~TRA Control Panel ~TRA System ~TRA Advanced ~TRA
26 Environment) to point to its installed location.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
27
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
28 Generally, when working on a single Django project, it's easier to use
29 ``manage.py``. Use ``django-admin.py`` with ``DJANGO_SETTINGS_MODULE`` or the
30 ``--settings`` command-line option, if you need to switch between multiple
31 Django settings files.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
32
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
33 The command-line examples throughout this appendix use ``django-admin.py`` to
34 be consistent, but any example can use ``manage.py`` just as well.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
35
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
36 Usage
37 =====
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
38
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
39 Here's how to use it::
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
40
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
41 django-admin.py <subcommand> [options]
42 manage.py <subcommand> [options]
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
43
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
44 ``subcommand`` should be one of the subcommands listed in this appendix.
45 ``options``, which is optional, should be zero or more of the options available
46 for the given subcommand.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
47
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
48 Getting runtime help
49 --------------------
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
50
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
51 Run ``django-admin.py help`` to display a list of all available subcommands.
52 Run ``django-admin.py help <subcommand>`` to display a description of the
53 given subcommand and a list of its available options.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
54
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
55 App names
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
56 ---------
57
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
58 Many subcommands take a list of "app names." An "app name" is the basename of
59 the package containing your models. For example, if your ``INSTALLED_APPS``
60 contains the string ``'mysite.blog'``, the app name is ``blog``.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
61
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
62 Determining the version
63 -----------------------
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
64
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
65 Run ``django-admin.py --version`` to display the current Django version.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
66
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
67 Examples of output::
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
68
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
69 1.1
70 1.0
71 0.96
72 0.97-pre-SVN-6069
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
73
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
74 Displaying debug output
75 -----------------------
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
76
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
77 Use ``--verbosity`` to specify the amount of notification and debug information
78 that ``django-admin.py`` should print to the console.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
79
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
80 Available subcommands
81 =====================
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
82
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
83 cleanup
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
84 -------
85
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
86 Can be run as a cronjob or directly to clean out old data from the database
87 (only expired sessions at the moment).
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
88
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
89 compilemessages
90 ---------------
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
91
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
92 Compiles .po files created with ``makemessages`` to .mo files for use with
93 the builtin gettext support. See Chapter 19.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
94
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
95 --locale
96 ~~~~~~~~
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
97
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
98 Use the ``--locale`` or ``-l`` option to specify the locale to process.
99 If not provided all locales are processed.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
100
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
101 Example usage::
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
102
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
103 django-admin.py compilemessages --locale=br_PT
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
104
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
105 createcachetable
106 ----------------
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
107
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
108 Creates a cache table with a given name for use with the database cache
109 backend. See Chapter 15.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
110
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
111 Example usage::
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
112
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
113 django-admin.py createcachetable my_cache_table
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
114
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
115 createsuperuser
116 ---------------
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
117
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
118 Creates a superuser account (a user who has all permissions). This is
119 useful if you need to create an initial superuser account but did not
120 do so during ``syncdb``, or if you need to programmatically generate
121 superuser accounts for your site(s).
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
122
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
123 When run interactively, this command will prompt for a password for
124 the new superuser account. When run non-interactively, no password
125 will be set, and the superuser account will not be able to log in until
126 a password has been manually set for it.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
127
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
128 The username and e-mail address for the new account can be supplied by
129 using the ``--username`` and ``--email`` arguments on the command
130 line. If either of those is not supplied, ``createsuperuser`` will prompt for
131 it when running interactively.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
132
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
133 This command is only available if Django's authentication system
134 (``django.contrib.auth``) is in ``INSTALLED_APPS``. See Chapter 14.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
135
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
136 dbshell
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
137 -------
138
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
139 Runs the command-line client for the database engine specified in your
140 ``DATABASE_ENGINE`` setting, with the connection parameters specified in your
141 ``DATABASE_USER``, ``DATABASE_PASSWORD``, etc., settings.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
142
fdc4800 @jacobian Fixed a bunch of reST markup errors.
jacobian authored
143 * For PostgreSQL, this runs the ``psql`` command-line client.
144 * For MySQL, this runs the ``mysql`` command-line client.
145 * For SQLite, this runs the ``sqlite3`` command-line client.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
146
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
147 This command assumes the programs are on your ``PATH`` so that a simple call to
148 the program name (``psql``, ``mysql``, ``sqlite3``) will find the program in
149 the right place. There's no way to specify the location of the program
150 manually.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
151
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
152 diffsettings
153 ------------
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
154
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
155 Displays differences between the current settings file and Django's default
156 settings.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
157
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
158 Settings that don't appear in the defaults are followed by ``"###"``. For
159 example, the default settings don't define ``ROOT_URLCONF``, so
160 ``ROOT_URLCONF`` is followed by ``"###"`` in the output of ``diffsettings``.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
161
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
162 Note that Django's default settings live in ``django/conf/global_settings.py``,
163 if you're ever curious to see the full list of defaults.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
164
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
165 dumpdata
166 --------
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
167
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
168 Outputs to standard output all data in the database associated with the named
169 application(s).
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
170
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
171 If no application name is provided, all installed applications will be dumped.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
172
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
173 The output of ``dumpdata`` can be used as input for ``loaddata``.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
174
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
175 Note that ``dumpdata`` uses the default manager on the model for selecting the
176 records to dump. If you're using a custom manager as the default manager and it
177 filters some of the available records, not all of the objects will be dumped.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
178
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
179 Example usage::
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
180
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
181 django-admin.py dumpdata books
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
182
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
183 Use the ``--exclude`` option to exclude a specific application from the
184 applications whose contents are output. For example, to specifically exclude
185 the `auth` application from the output, you would call::
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
186
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
187 django-admin.py dumpdata --exclude=auth
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
188
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
189 If you want to exclude multiple applications, use multiple ``--exclude``
190 directives::
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
191
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
192 django-admin.py dumpdata --exclude=auth --exclude=contenttypes
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
193
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
194 By default, ``dumpdata`` will format its output in JSON, but you can use the
195 ``--format`` option to specify another format. Currently supported formats
196 are listed in :ref:`serialization-formats`.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
197
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
198 By default, ``dumpdata`` will output all data on a single line. This isn't
199 easy for humans to read, so you can use the ``--indent`` option to
200 pretty-print the output with a number of indentation spaces.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
201
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
202 In addition to specifying application names, you can provide a list of
203 individual models, in the form of ``appname.Model``. If you specify a model
204 name to ``dumpdata``, the dumped output will be restricted to that model,
205 rather than the entire application. You can also mix application names and
206 model names.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
207
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
208 flush
209 -----
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
210
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
211 Returns the database to the state it was in immediately after syncdb was
212 executed. This means that all data will be removed from the database, any
213 post-synchronization handlers will be re-executed, and the ``initial_data``
214 fixture will be re-installed.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
215
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
216 Use the ``--noinput`` option to suppress all user prompting, such as "Are
217 you sure?" confirmation messages. This is useful if ``django-admin.py`` is
218 being executed as an unattended, automated script.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
219
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
220 inspectdb
221 ---------
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
222
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
223 Introspects the database tables in the database pointed-to by the
224 ``DATABASE_NAME`` setting and outputs a Django model module (a ``models.py``
225 file) to standard output.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
226
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
227 Use this if you have a legacy database with which you'd like to use Django.
228 The script will inspect the database and create a model for each table within
229 it.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
230
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
231 As you might expect, the created models will have an attribute for every field
232 in the table. Note that ``inspectdb`` has a few special cases in its field-name
233 output:
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
234
fdc4800 @jacobian Fixed a bunch of reST markup errors.
jacobian authored
235 * If ``inspectdb`` cannot map a column's type to a model field type, it'll
236 use ``TextField`` and will insert the Python comment
237 ``'This field type is a guess.'`` next to the field in the generated
238 model.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
239
fdc4800 @jacobian Fixed a bunch of reST markup errors.
jacobian authored
240 * If the database column name is a Python reserved word (such as
241 ``'pass'``, ``'class'`` or ``'for'``), ``inspectdb`` will append
242 ``'_field'`` to the attribute name. For example, if a table has a column
243 ``'for'``, the generated model will have a field ``'for_field'``, with
244 the ``db_column`` attribute set to ``'for'``. ``inspectdb`` will insert
245 the Python comment
246 ``'Field renamed because it was a Python reserved word.'`` next to the
247 field.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
248
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
249 This feature is meant as a shortcut, not as definitive model generation. After
250 you run it, you'll want to look over the generated models yourself to make
251 customizations. In particular, you'll need to rearrange models' order, so that
252 models that refer to other models are ordered properly.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
253
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
254 Primary keys are automatically introspected for PostgreSQL, MySQL and
255 SQLite, in which case Django puts in the ``primary_key=True`` where
256 needed.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
257
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
258 ``inspectdb`` works with PostgreSQL, MySQL and SQLite. Foreign-key detection
259 only works in PostgreSQL and with certain types of MySQL tables.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
260
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
261 loaddata <fixture fixture ...>
262 ------------------------------
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
263
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
264 Searches for and loads the contents of the named fixture into the database.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
265
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
266 What's a "fixture"?
267 ~~~~~~~~~~~~~~~~~~~
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
268
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
269 A *fixture* is a collection of files that contain the serialized contents of
270 the database. Each fixture has a unique name, and the files that comprise the
271 fixture can be distributed over multiple directories, in multiple applications.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
272
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
273 Django will search in three locations for fixtures:
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
274
fdc4800 @jacobian Fixed a bunch of reST markup errors.
jacobian authored
275 1. In the ``fixtures`` directory of every installed application
276 2. In any directory named in the ``FIXTURE_DIRS`` setting
277 3. In the literal path named by the fixture
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
278
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
279 Django will load any and all fixtures it finds in these locations that match
280 the provided fixture names.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
281
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
282 If the named fixture has a file extension, only fixtures of that type
283 will be loaded. For example::
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
284
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
285 django-admin.py loaddata mydata.json
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
286
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
287 would only load JSON fixtures called ``mydata``. The fixture extension
288 must correspond to the registered name of a
289 serializer (e.g., ``json`` or ``xml``). For more on serializers, see the Django
290 docs.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
291
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
292 If you omit the extensions, Django will search all available fixture types
293 for a matching fixture. For example::
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
294
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
295 django-admin.py loaddata mydata
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
296
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
297 would look for any fixture of any fixture type called ``mydata``. If a fixture
298 directory contained ``mydata.json``, that fixture would be loaded
299 as a JSON fixture.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
300
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
301 The fixtures that are named can include directory components. These
302 directories will be included in the search path. For example::
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
303
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
304 django-admin.py loaddata foo/bar/mydata.json
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
305
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
306 would search ``<appname>/fixtures/foo/bar/mydata.json`` for each installed
307 application, ``<dirname>/foo/bar/mydata.json`` for each directory in
308 ``FIXTURE_DIRS``, and the literal path ``foo/bar/mydata.json``.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
309
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
310 When fixture files are processed, the data is saved to the database as is.
311 Model defined ``save`` methods and ``pre_save`` signals are not called.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
312
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
313 Note that the order in which fixture files are processed is undefined. However,
314 all fixture data is installed as a single transaction, so data in
315 one fixture can reference data in another fixture. If the database backend
316 supports row-level constraints, these constraints will be checked at the
317 end of the transaction.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
318
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
319 The ``dumpdata`` command can be used to generate input for ``loaddata``.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
320
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
321 Compressed fixtures
322 ~~~~~~~~~~~~~~~~~~~
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
323
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
324 Fixtures may be compressed in ``zip``, ``gz``, or ``bz2`` format. For example::
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
325
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
326 django-admin.py loaddata mydata.json
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
327
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
328 would look for any of ``mydata.json``, ``mydata.json.zip``,
329 ``mydata.json.gz``, or ``mydata.json.bz2``. The first file contained within a
330 zip-compressed archive is used.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
331
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
332 Note that if two fixtures with the same name but different
333 fixture type are discovered (for example, if ``mydata.json`` and
334 ``mydata.xml.gz`` were found in the same fixture directory), fixture
335 installation will be aborted, and any data installed in the call to
336 ``loaddata`` will be removed from the database.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
337
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
338 .. admonition:: MySQL and Fixtures
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
339
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
340 Unfortunately, MySQL isn't capable of completely supporting all the
341 features of Django fixtures. If you use MyISAM tables, MySQL doesn't
342 support transactions or constraints, so you won't get a rollback if
343 multiple fixture files are found, or validation of fixture data fails.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
344
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
345 If you use InnoDB tables, you won't be able to have any forward
346 references in your data files -- MySQL doesn't provide a mechanism to
347 defer checking of row constraints until a transaction is committed.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
348
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
349 makemessages
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
350 ------------
351
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
352 Runs over the entire source tree of the current directory and pulls out all
353 strings marked for translation. It creates (or updates) a message file in the
354 conf/locale (in the django tree) or locale (for project and application)
355 directory. After making changes to the messages files you need to compile them
356 with ``compilemessages`` for use with the builtin gettext support. See Chapter
357 19 for details.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
358
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
359 --all
360 ~~~~~
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
361
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
362 Use the ``--all`` or ``-a`` option to update the message files for all
363 available languages.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
364
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
365 Example usage::
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
366
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
367 django-admin.py makemessages --all
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
368
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
369 --extension
370 ~~~~~~~~~~~
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
371
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
372 Use the ``--extension`` or ``-e`` option to specify a list of file extensions
373 to examine (default: ".html").
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
374
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
375 Example usage::
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
376
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
377 django-admin.py makemessages --locale=de --extension xhtml
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
378
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
379 Separate multiple extensions with commas or use -e or --extension multiple times::
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
380
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
381 django-admin.py makemessages --locale=de --extension=html,txt --extension xml
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
382
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
383 --locale
384 ~~~~~~~~
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
385
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
386 Use the ``--locale`` or ``-l`` option to specify the locale to process.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
387
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
388 Example usage::
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
389
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
390 django-admin.py makemessages --locale=br_PT
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
391
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
392 --domain
393 ~~~~~~~~
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
394
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
395 Use the ``--domain`` or ``-d`` option to change the domain of the messages files.
396 Currently supported:
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
397
fdc4800 @jacobian Fixed a bunch of reST markup errors.
jacobian authored
398 * ``django`` for all ``*.py`` and ``*.html`` files (default)
399 * ``djangojs`` for ``*.js`` files
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
400
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
401 .. _django-admin-reset:
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
402
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
403 reset <appname appname ...>
404 ---------------------------
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
405
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
406 Executes the equivalent of ``sqlreset`` for the given app name(s).
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
407
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
408 --noinput
409 ~~~~~~~~~
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
410
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
411 Use the ``--noinput`` option to suppress all user prompting, such as
412 "Are you sure?" confirmation messages. This is useful if ``django-admin.py``
413 is being executed as an unattended, automated script.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
414
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
415 runfcgi [options]
416 -----------------
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
417
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
418 Starts a set of FastCGI processes suitable for use with any Web server that
419 supports the FastCGI protocol. See Chapter 12 for details. Requires the Python
420 FastCGI module from flup: http://www.saddi.com/software/flup/
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
421
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
422 runserver
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
423 ---------
424
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
425 Starts a lightweight development Web server on the local machine. By default,
426 the server runs on port 8000 on the IP address 127.0.0.1. You can pass in an
427 IP address and port number explicitly.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
428
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
429 If you run this script as a user with normal privileges (recommended), you
430 might not have access to start a port on a low port number. Low port numbers
431 are reserved for the superuser (root).
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
432
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
433 DO NOT USE THIS SERVER IN A PRODUCTION SETTING. It has not gone through
434 security audits or performance tests. (And that's how it's gonna stay. We're in
435 the business of making Web frameworks, not Web servers, so improving this
436 server to be able to handle a production environment is outside the scope of
437 Django.)
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
438
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
439 The development server automatically reloads Python code for each request, as
440 needed. You don't need to restart the server for code changes to take effect.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
441
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
442 When you start the server, and each time you change Python code while the
443 server is running, the server will validate all of your installed models. (See
444 the ``validate`` command below.) If the validator finds errors, it will print
445 them to standard output, but it won't stop the server.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
446
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
447 You can run as many servers as you want, as long as they're on separate ports.
448 Just execute ``django-admin.py runserver`` more than once.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
449
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
450 Note that the default IP address, 127.0.0.1, is not accessible from other
451 machines on your network. To make your development server viewable to other
452 machines on the network, use its own IP address (e.g. ``192.168.2.1``) or
453 ``0.0.0.0`` (which you can use if you don't know what your IP address is
454 on the network).
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
455
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
456 Use the ``--adminmedia`` option to tell Django where to find the various CSS
457 and JavaScript files for the Django admin interface. Normally, the development
458 server serves these files out of the Django source tree magically, but you'd
459 want to use this if you made any changes to those files for your own site.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
460
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
461 Example usage::
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
462
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
463 django-admin.py runserver --adminmedia=/tmp/new-admin-style/
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
464
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
465 Use the ``--noreload`` option to disable the use of the auto-reloader. This
466 means any Python code changes you make while the server is running will *not*
467 take effect if the particular Python modules have already been loaded into
468 memory.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
469
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
470 Example usage::
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
471
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
472 django-admin.py runserver --noreload
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
473
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
474 Examples of using different ports and addresses
475 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
476
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
477 Port 8000 on IP address 127.0.0.1::
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
478
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
479 django-admin.py runserver
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
480
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
481 Port 8000 on IP address 1.2.3.4::
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
482
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
483 django-admin.py runserver 1.2.3.4:8000
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
484
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
485 Port 7000 on IP address 127.0.0.1::
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
486
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
487 django-admin.py runserver 7000
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
488
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
489 Port 7000 on IP address 1.2.3.4::
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
490
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
491 django-admin.py runserver 1.2.3.4:7000
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
492
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
493 Serving static files with the development server
494 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
495
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
496 By default, the development server doesn't serve any static files for your site
497 (such as CSS files, images, things under ``MEDIA_URL`` and so forth).
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
498
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
499 shell
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
500 -----
501
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
502 Starts the Python interactive interpreter.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
503
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
504 Django will use IPython (http://ipython.scipy.org/), if it's installed. If you
505 have IPython installed and want to force use of the "plain" Python interpreter,
506 use the ``--plain`` option, like so::
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
507
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
508 django-admin.py shell --plain
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
509
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
510 sql <appname appname ...>
511 -------------------------
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
512
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
513 Prints the CREATE TABLE SQL statements for the given app name(s).
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
514
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
515 sqlall <appname appname ...>
516 ----------------------------
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
517
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
518 Prints the CREATE TABLE and initial-data SQL statements for the given app name(s).
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
519
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
520 Refer to the description of ``sqlcustom`` for an explanation of how to
521 specify initial data.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
522
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
523 sqlclear <appname appname ...>
524 ------------------------------
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
525
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
526 Prints the DROP TABLE SQL statements for the given app name(s).
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
527
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
528 sqlcustom <appname appname ...>
529 -------------------------------
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
530
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
531 Prints the custom SQL statements for the given app name(s).
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
532
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
533 For each model in each specified app, this command looks for the file
534 ``<appname>/sql/<modelname>.sql``, where ``<appname>`` is the given app name and
535 ``<modelname>`` is the model's name in lowercase. For example, if you have an
536 app ``news`` that includes a ``Story`` model, ``sqlcustom`` will attempt
537 to read a file ``news/sql/story.sql`` and append it to the output of this
538 command.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
539
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
540 Each of the SQL files, if given, is expected to contain valid SQL. The SQL
541 files are piped directly into the database after all of the models'
542 table-creation statements have been executed. Use this SQL hook to make any
543 table modifications, or insert any SQL functions into the database.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
544
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
545 Note that the order in which the SQL files are processed is undefined.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
546
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
547 sqlflush
548 --------
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
549
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
550 Prints the SQL statements that would be executed for the `flush`_ command.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
551
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
552 sqlindexes <appname appname ...>
553 --------------------------------
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
554
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
555 Prints the CREATE INDEX SQL statements for the given app name(s).
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
556
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
557 sqlreset <appname appname ...>
558 ------------------------------
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
559
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
560 Prints the DROP TABLE SQL, then the CREATE TABLE SQL, for the given app name(s).
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
561
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
562 sqlsequencereset <appname appname ...>
563 --------------------------------------
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
564
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
565 Prints the SQL statements for resetting sequences for the given app name(s).
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
566
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
567 startapp <appname>
568 ------------------
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
569
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
570 Creates a Django app directory structure for the given app name in the current
571 directory.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
572
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
573 startproject <projectname>
574 --------------------------
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
575
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
576 Creates a Django project directory structure for the given project name in the
577 current directory.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
578
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
579 This command is disabled when the ``--settings`` option to
580 ``django-admin.py`` is used, or when the environment variable
581 ``DJANGO_SETTINGS_MODULE`` has been set. To re-enable it in these
582 situations, either omit the ``--settings`` option or unset
583 ``DJANGO_SETTINGS_MODULE``.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
584
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
585 syncdb
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
586 ------
587
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
588 Creates the database tables for all apps in ``INSTALLED_APPS`` whose tables
589 have not already been created.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
590
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
591 Use this command when you've added new applications to your project and want to
592 install them in the database. This includes any apps shipped with Django that
593 might be in ``INSTALLED_APPS`` by default. When you start a new project, run
594 this command to install the default apps.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
595
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
596 .. admonition:: Syncdb will not alter existing tables
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
597
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
598 ``syncdb`` will only create tables for models which have not yet been
599 installed. It will *never* issue ``ALTER TABLE`` statements to match
600 changes made to a model class after installation. Changes to model classes
601 and database schemas often involve some form of ambiguity and, in those
602 cases, Django would have to guess at the correct changes to make. There is
603 a risk that critical data would be lost in the process.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
604
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
605 If you have made changes to a model and wish to alter the database tables
606 to match, use the ``sql`` command to display the new SQL structure and
607 compare that to your existing table schema to work out the changes.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
608
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
609 If you're installing the ``django.contrib.auth`` application, ``syncdb`` will
610 give you the option of creating a superuser immediately.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
611
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
612 ``syncdb`` will also search for and install any fixture named ``initial_data``
613 with an appropriate extension (e.g. ``json`` or ``xml``). See the
614 documentation for ``loaddata`` for details on the specification of fixture
615 data files.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
616
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
617 --noinput
618 ~~~~~~~~~
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
619
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
620 Use the ``--noinput`` option to suppress all user prompting, such as
621 "Are you sure?" confirmation messages. This is useful if ``django-admin.py``
622 is being executed as an unattended, automated script.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
623
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
624 test
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
625 ----
626
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
627 Runs tests for all installed models. See the Django documentation for more
628 on testing.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
629
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
630 --noinput
631 ~~~~~~~~~
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
632
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
633 Use the ``--noinput`` option to suppress all user prompting, such as
634 "Are you sure?" confirmation messages. This is useful if ``django-admin.py``
635 is being executed as an unattended, automated script.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
636
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
637 testserver <fixture fixture ...>
638 --------------------------------
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
639
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
640 Runs a Django development server (as in ``runserver``) using data from the
641 given fixture(s).
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
642
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
643 For more, see the Django documentation.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
644
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
645 validate
646 --------
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
647
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
648 Validates all installed models (according to the ``INSTALLED_APPS`` setting)
649 and prints validation errors to standard output.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
650
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
651 Default options
652 ===============
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
653
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
654 Although some subcommands may allow their own custom options, every subcommand
655 allows for the following options:
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
656
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
657 --pythonpath
658 ------------
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
659
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
660 Example usage::
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
661
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
662 django-admin.py syncdb --pythonpath='/home/djangoprojects/myproject'
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
663
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
664 Adds the given filesystem path to the Python import search path. If this
665 isn't provided, ``django-admin.py`` will use the ``PYTHONPATH`` environment
666 variable.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
667
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
668 Note that this option is unnecessary in ``manage.py``, because it takes care of
669 setting the Python path for you.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
670
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
671 --settings
672 ----------
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
673
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
674 Example usage::
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
675
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
676 django-admin.py syncdb --settings=mysite.settings
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
677
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
678 Explicitly specifies the settings module to use. The settings module should be
679 in Python package syntax, e.g. ``mysite.settings``. If this isn't provided,
680 ``django-admin.py`` will use the ``DJANGO_SETTINGS_MODULE`` environment
681 variable.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
682
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
683 Note that this option is unnecessary in ``manage.py``, because it uses
684 ``settings.py`` from the current project by default.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
685
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
686 --traceback
687 -----------
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
688
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
689 Example usage::
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
690
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
691 django-admin.py syncdb --traceback
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
692
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
693 By default, ``django-admin.py`` will show a simple error message whenever an
694 error occurs. If you specify ``--traceback``, ``django-admin.py`` will
695 output a full stack trace whenever an exception is raised.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
696
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
697 --verbosity
698 -----------
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
699
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
700 Example usage::
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
701
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
702 django-admin.py syncdb --verbosity 2
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
703
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
704 Use ``--verbosity`` to specify the amount of notification and debug information
705 that ``django-admin.py`` should print to the console.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
706
fdc4800 @jacobian Fixed a bunch of reST markup errors.
jacobian authored
707 * ``0`` means no output.
708 * ``1`` means normal output (default).
709 * ``2`` means verbose output.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
710
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
711 Extra niceties
712 ==============
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
713
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
714 Syntax coloring
715 ---------------
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
716
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
717 The ``django-admin.py`` / ``manage.py`` commands that output SQL to standard
718 output will use pretty color-coded output if your terminal supports
719 ANSI-colored output. It won't use the color codes if you're piping the
720 command's output to another program.
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
721
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
722 Bash completion
723 ---------------
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
724
d40cfe7 @jacobian Restored *2.0* version of the book, not 1.0!
jacobian authored
725 If you use the Bash shell, consider installing the Django bash completion
726 script, which lives in ``extras/django_bash_completion`` in the Django
727 distribution. It enables tab-completion of ``django-admin.py`` and
728 ``manage.py`` commands, so you can, for instance...
acc918f @jacobian Initial import of djangobook from private SVN repo.
jacobian authored
729
fdc4800 @jacobian Fixed a bunch of reST markup errors.
jacobian authored
730 * Type ``django-admin.py``.
731 * Press [TAB] to see all available options.
732 * Type ``sql``, then [TAB], to see all available options whose names start
546edd4 @jay754 Update broken links
jay754 authored
733 with ``sql``.
Something went wrong with that request. Please try again.