community.general.django_dumpdata module – Wrapper for django-admin dumpdata
Note
This module is part of the community.general collection (version 11.3.0).
You might already have this collection installed if you are using the ansible
package.
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install community.general
.
To use it in a playbook, specify: community.general.django_dumpdata
.
New in community.general 11.3.0
Synopsis
This module is a wrapper for the execution of
django-admin dumpdata
.
Parameters
Parameter |
Comments |
---|---|
Dump all records, including those which might otherwise be filtered or modified by a custom manager. Choices:
|
|
Dump only the applications and models listed in the dump. Format must be either If not passed, all applications and models are to be dumped. |
|
Specify the database to be used. Default: |
|
Applications or models to be excluded. Format must be either |
|
Path to the output file. The fixture filename may end with This corresponds to the |
|
Serialization format of the output data. Choices:
|
|
Indentation size for the output. Default is not to indent, so the output is generated in one single line. |
|
Use natural keys when serializing for foreign keys. Choices:
|
|
Omit primary keys when serializing. Choices:
|
|
List of primary keys to include in the dump. Only available when dumping one single model. |
|
Adds the given filesystem path to the Python import search path. The value is passed as is to the |
|
Specifies the settings module to use. The value is passed as is to the |
|
Skips running system checks prior to running the command. Choices:
|
|
Provides a full stack trace in the output when a Choices:
|
|
Use the the Python interpreter from this virtual environment. Pass the path to the root of the virtualenv, not the |
|
Specifies the amount of notification and debug information in the output of Choices:
|
Attributes
Attribute |
Support |
Description |
---|---|---|
Support: none |
Can run in |
|
Support: none |
Returns details on what has changed (or possibly needs changing in |
Notes
Note
The
django-admin
command is always executed using theC
locale, and the option--no-color
is always passed.As it is now, the module is not idempotent. Ensuring idempotency for this case can be a bit tricky, because it would amount to ensuring beforehand that all the data in the fixture file is already in the database, which is not a trivial feat. Unfortunately, neither
django loaddata
nordjango dumpdata
have a--dry-run
option, so the only way to know whether there is a change or not is to actually load or dump the data.
See Also
See also
- django-admin and manage.py in official Django documentation
Refer to this documentation for the builtin commands and options of
django-admin
. Please make sure that you select the right version of Django in the version selector on that page.
Examples
- name: Dump all data
community.general.django_dumpdata:
settings: myproject.settings
fixture: /tmp/mydata.json
- name: Dump data excluding certain apps, into a compressed JSON file
community.general.django_dumpdata:
settings: myproject.settings
database: myotherdb
excludes:
- auth
- contenttypes
fixture: /tmp/mydata.json.gz
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
Command-line execution information. Returned: success and |
|
Version of Django. Returned: always Sample: |