docs/management_commands.rst
The export command allows you to export data from a specified Django model
or a resource class. The exported data can be saved in different formats, such
as CSV or XLSX.
.. code-block:: bash
python manage.py export <format> <resource> [--encoding ENCODING]
.. code-block:: bash
python manage.py export CSV auth.User
This command will export the User model data in CSV format using utf-8 encoding.
Another example:
.. code-block:: bash
python manage.py export XLSX mymodule.resources.MyResource
This command will export the data from MyResource resource in XLSX format.
The import command allows you to import data from a file using a specified
Django model or a custom resource class.
.. code-block:: bash
python manage.py import <resource> <import_file_name> [--format FORMAT] [--encoding ENCODING] [--dry-run] [--raise-errors]
- can be used to indicate stdin).Import data from file into auth.User model using default model resource:
.. code-block:: bash
python manage.py import auth.User users.csv
Import data from file using custom model resource, raising errors:
.. code-block:: bash
python manage.py import --raise-errors helper.MyUserResource users.csv