community.general.django_loaddata module – Wrapper for django-admin loaddata
Note
This module is part of the community.general collection (version 12.6.1).
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_loaddata.
New in community.general 11.3.0
Synopsis
- This module is a wrapper for the execution of
django-admin loaddata.
Parameters
Parameter | Comments |
|---|---|
app string | Specifies a single app to look for fixtures in rather than looking in all apps. |
database string | Specify the database to be used. Default: |
excludes list / elements=string | Applications or models to be excluded. Format must be either |
fixtures list / elements=path | List of paths to the fixture files. |
format string | Serialization format of the output data. Choices:
|
ignore_non_existent boolean | Ignores fields and models that may have been removed since the fixture was originally generated. Choices:
|
pythonpath path | Adds the given filesystem path to the Python import search path. The value is passed as is to the |
settings string / required | Specifies the settings module to use. The value is passed as is to the |
skip_checks boolean | Skips running system checks prior to running the command. Choices:
|
traceback boolean | Provides a full stack trace in the output when a Choices:
|
venv path | Use the Python interpreter from this virtual environment. Pass the path to the root of the virtualenv, not the |
verbosity integer | Specifies the amount of notification and debug information in the output of Choices:
|
Attributes
Attribute | Support | Description |
|---|---|---|
check_mode | Support: none | Can run in |
diff_mode | Support: none | Returns details on what has changed (or possibly needs changing in |
Notes
Note
- The
django-admincommand is always executed using theClocale, and the option--no-coloris 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 loaddatanordjango dumpdatahave a--dry-runoption, 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
- name: Create cache table in the other database
community.general.django_createcachetable:
database: myotherdb
settings: fancysite.settings
pythonpath: /home/joedoe/project/fancysite
venv: /home/joedoe/project/fancysite/venv
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key | Description |
|---|---|
run_info dictionary | Command-line execution information. Returned: success and |
version string | Version of Django. Returned: always Sample: |
Collection links
© 2012–2018 Michael DeHaan
© 2018–2025 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/projects/ansible/latest/collections/community/general/django_loaddata_module.html