mirror of
https://github.com/django/django.git
synced 2025-07-24 05:36:15 +00:00
Fixed #27978 -- Allowed loaddata to read data from stdin.
Thanks Squareweave for the django-loaddata-stdin project from which this is adapted.
This commit is contained in:
parent
c930c241f8
commit
af1fa5e7da
5 changed files with 78 additions and 0 deletions
|
@ -416,6 +416,14 @@ originally generated.
|
|||
|
||||
Specifies a single app to look for fixtures in rather than looking in all apps.
|
||||
|
||||
.. django-admin-option:: --format FORMAT
|
||||
|
||||
.. versionadded:: 2.0
|
||||
|
||||
Specifies the :ref:`serialization format <serialization-formats>` (e.g.,
|
||||
``json`` or ``xml``) for fixtures :ref:`read from stdin
|
||||
<loading-fixtures-stdin>`.
|
||||
|
||||
.. django-admin-option:: --exclude EXCLUDE, -e EXCLUDE
|
||||
|
||||
.. versionadded:: 1.11
|
||||
|
@ -552,6 +560,27 @@ defined, name the fixture ``mydata.master.json`` or
|
|||
``mydata.master.json.gz`` and the fixture will only be loaded when you
|
||||
specify you want to load data into the ``master`` database.
|
||||
|
||||
.. _loading-fixtures-stdin:
|
||||
|
||||
Loading fixtures from ``stdin``
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. versionadded:: 2.0
|
||||
|
||||
You can use a dash as the fixture name to load input from ``sys.stdin``. For
|
||||
example::
|
||||
|
||||
django-admin loaddata --format=json -
|
||||
|
||||
When reading from ``stdin``, the :option:`--format <loaddata --format>` option
|
||||
is required to specify the :ref:`serialization format <serialization-formats>`
|
||||
of the input (e.g., ``json`` or ``xml``).
|
||||
|
||||
Loading from ``stdin`` is useful with standard input and output redirections.
|
||||
For example::
|
||||
|
||||
django-admin dumpdata --format=json --database=test app_label.ModelName | django-admin loaddata --format=json --database=prod -
|
||||
|
||||
``makemessages``
|
||||
----------------
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue