1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #4924: added support for loading compressed fixtures. Thanks to Lars Yencken and Jeremy Dunck.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@9527 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Jacob Kaplan-Moss
2008-11-24 20:42:09 +00:00
parent 436a808ce2
commit 089ab18c02
7 changed files with 139 additions and 66 deletions

View File

@@ -290,6 +290,9 @@ loaddata <fixture fixture ...>
Searches for and loads the contents of the named fixture into the database.
What's a "fixture"?
~~~~~~~~~~~~~~~~~~~
A *fixture* is a collection of files that contain the serialized contents of
the database. Each fixture has a unique name, and the files that comprise the
fixture can be distributed over multiple directories, in multiple applications.
@@ -309,21 +312,17 @@ will be loaded. For example::
django-admin.py loaddata mydata.json
would only load JSON fixtures called ``mydata``. The fixture extension
must correspond to the registered name of a serializer (e.g., ``json`` or
``xml``).
must correspond to the registered name of a
:ref:`serializer <serialization-formats>` (e.g., ``json`` or ``xml``).
If you omit the extension, Django will search all available fixture types
If you omit the extensions, Django will search all available fixture types
for a matching fixture. For example::
django-admin.py loaddata mydata
would look for any fixture of any fixture type called ``mydata``. If a fixture
directory contained ``mydata.json``, that fixture would be loaded
as a JSON fixture. However, if two fixtures with the same name but different
fixture type are discovered (for example, if ``mydata.json`` and
``mydata.xml`` were found in the same fixture directory), fixture
installation will be aborted, and any data installed in the call to
``loaddata`` will be removed from the database.
as a JSON fixture.
The fixtures that are named can include directory components. These
directories will be included in the search path. For example::
@@ -342,6 +341,23 @@ end of the transaction.
The ``dumpdata`` command can be used to generate input for ``loaddata``.
Compressed fixtures
~~~~~~~~~~~~~~~~~~~
Fixtures may be compressed in ``zip``, ``gz``, or ``bz2`` format. For example::
django-admin.py loaddata mydata.json
would look for any of ``mydata.json``, ``mydata.json.zip``,
``mydata.json.gz``, or ``mydata.json.bz2``. The first file contained within a
zip-compressed archive is used.
Note that if two fixtures with the same name but different
fixture type are discovered (for example, if ``mydata.json`` and
``mydata.xml.gz`` were found in the same fixture directory), fixture
installation will be aborted, and any data installed in the call to
``loaddata`` will be removed from the database.
.. admonition:: MySQL and Fixtures
Unfortunately, MySQL isn't capable of completely supporting all the