Fixed #17166 -- Documented how FIXTURE_DIRS works in the inital data how-to, and edited related bits in the settings reference.
Performed minor edits for consistency while I was there. git-svn-id: http://code.djangoproject.com/svn/django/trunk@17558 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
9d0bf66273
commit
1d78897c5d
|
@ -13,6 +13,8 @@ but initial SQL is also quite a bit more flexible.
|
||||||
.. _initial data as sql: `providing initial sql data`_
|
.. _initial data as sql: `providing initial sql data`_
|
||||||
.. _initial data via fixtures: `providing initial data with fixtures`_
|
.. _initial data via fixtures: `providing initial data with fixtures`_
|
||||||
|
|
||||||
|
.. _initial-data-via-fixtures:
|
||||||
|
|
||||||
Providing initial data with fixtures
|
Providing initial data with fixtures
|
||||||
====================================
|
====================================
|
||||||
|
|
||||||
|
@ -65,12 +67,12 @@ And here's that same fixture as YAML:
|
||||||
|
|
||||||
You'll store this data in a ``fixtures`` directory inside your app.
|
You'll store this data in a ``fixtures`` directory inside your app.
|
||||||
|
|
||||||
Loading data is easy: just call :djadmin:`manage.py loaddata fixturename
|
Loading data is easy: just call :djadmin:`manage.py loaddata <fixturename>
|
||||||
<loaddata>`, where *fixturename* is the name of the fixture file you've created.
|
<loaddata>`, where ``<fixturename>`` is the name of the fixture file you've
|
||||||
Every time you run :djadmin:`loaddata` the data will be read from the fixture
|
created. Every time you run :djadmin:`loaddata` the data will be read from the
|
||||||
and re-loaded into the database. Note that this means that if you change one of
|
fixture and re-loaded into the database. Note that this means that if you
|
||||||
the rows created by a fixture and then run :djadmin:`loaddata` again you'll
|
change one of the rows created by a fixture and then run :djadmin:`loaddata`
|
||||||
wipe out any changes you've made.
|
again you'll wipe out any changes you've made.
|
||||||
|
|
||||||
Automatically loading initial data fixtures
|
Automatically loading initial data fixtures
|
||||||
-------------------------------------------
|
-------------------------------------------
|
||||||
|
@ -80,6 +82,17 @@ be loaded every time you run :djadmin:`syncdb`. This is extremely convenient,
|
||||||
but be careful: remember that the data will be refreshed *every time* you run
|
but be careful: remember that the data will be refreshed *every time* you run
|
||||||
:djadmin:`syncdb`. So don't use ``initial_data`` for data you'll want to edit.
|
:djadmin:`syncdb`. So don't use ``initial_data`` for data you'll want to edit.
|
||||||
|
|
||||||
|
Where Django finds fixture files
|
||||||
|
--------------------------------
|
||||||
|
|
||||||
|
By default, Django looks in the ``fixtures`` directory inside each app for
|
||||||
|
fixtures. You can set the :setting:`FIXTURE_DIRS` setting to a list of
|
||||||
|
additional directories where Django should look.
|
||||||
|
|
||||||
|
When running :djadmin:`manage.py loaddata <loaddata>`, you can also
|
||||||
|
specify an absolute path to a fixture file, which overrides searching
|
||||||
|
the usual directories.
|
||||||
|
|
||||||
.. seealso::
|
.. seealso::
|
||||||
|
|
||||||
Fixtures are also used by the :ref:`testing framework
|
Fixtures are also used by the :ref:`testing framework
|
||||||
|
|
|
@ -1098,9 +1098,12 @@ FIXTURE_DIRS
|
||||||
|
|
||||||
Default: ``()`` (Empty tuple)
|
Default: ``()`` (Empty tuple)
|
||||||
|
|
||||||
List of locations of the fixture data files, in search order. Note that
|
List of directories searched for fixture files, in addition to the
|
||||||
these paths should use Unix-style forward slashes, even on Windows. See
|
``fixtures`` directory of each application, in search order.
|
||||||
:doc:`/topics/testing`.
|
|
||||||
|
Note that these paths should use Unix-style forward slashes, even on Windows.
|
||||||
|
|
||||||
|
See :ref:`initial-data-via-fixtures` and :ref:`topics-testing-fixtures`.
|
||||||
|
|
||||||
FORCE_SCRIPT_NAME
|
FORCE_SCRIPT_NAME
|
||||||
------------------
|
------------------
|
||||||
|
@ -1945,8 +1948,10 @@ TEMPLATE_DIRS
|
||||||
|
|
||||||
Default: ``()`` (Empty tuple)
|
Default: ``()`` (Empty tuple)
|
||||||
|
|
||||||
List of locations of the template source files, in search order. Note that
|
List of locations of the template source files searched by
|
||||||
these paths should use Unix-style forward slashes, even on Windows.
|
:class:`django.template.loaders.filesystem.Loader`, in search order.
|
||||||
|
|
||||||
|
Note that these paths should use Unix-style forward slashes, even on Windows.
|
||||||
|
|
||||||
See :doc:`/topics/templates`.
|
See :doc:`/topics/templates`.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue