Note
This module is part of the community.general collection (version 10.7.3).
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. You need further requirements to be able to use this module, see Requirements for details.
To use it in a playbook, specify: community.general.django_manage.
manage.py application frontend to django-admin. With the virtualenv parameter, all management commands are executed by the given virtualenv installation.The below requirements are needed on the host that executes this module.
Parameter | Comments |
|---|---|
ack_venv_creation_deprecation boolean added in community.general 5.8.0 | This option no longer has any effect since community.general 9.0.0. It will be removed from community.general 11.0.0. Choices:
|
apps string | A list of space-delimited apps to target. Used by the |
cache_table string | The name of the table used for database-backed caching. Used by the |
clear boolean | Clear the existing files before trying to copy or link the original file. Used only with the Choices:
|
command string / required | The name of the Django management command to run. The commands listed below are built in this module and have some basic parameter validation.
Custom commands can be entered, but they fail unless they are known to Django. Custom commands that may prompt for user input should be run with the Support for the values |
database string | The database to target. Used by the |
failfast aliases: fail_fast boolean | Fail the command immediately if a test fails. Used by the Choices:
|
fixtures string | A space-delimited list of fixture file names to load in the database. Required by the |
link boolean | Creates links to the files instead of copying them, you can only use this parameter with Choices:
|
merge boolean | Runs out-of-order or missing migrations as they are not rollback migrations, you can only use this parameter with Choices:
|
project_path aliases: app_path, chdir path / required | The path to the root of the Django application where |
pythonpath aliases: python_path path | A directory to add to the Python path. Typically used to include the settings module if it is located external to the application directory. This would be equivalent to adding |
settings path | The Python path to the application’s settings module, such as |
skip boolean | Skips over out-of-order missing migrations, you can only use this parameter with Choices:
|
testrunner aliases: test_runner string | Controls the test runner class that is used to execute tests. This parameter is passed as-is to |
virtualenv aliases: virtual_env path | An optional path to a The virtual environment must exist, otherwise the module fails. |
Attribute | Support | Description |
|---|---|---|
check_mode | Support: none | Can run in |
diff_mode | Support: none | Will return details on what has changed (or possibly needs changing in |
Note
virtualenv parameter is specified and a virtual environment does not already exist at the given location. This behavior changed in community.general version 9.0.0.createcachetable command to detect table existence, unfortunately.collectstatic command, you must have enabled staticfiles in your settings.manage.py application must be executable (rwxr-xr-x), and must have a valid shebang, for example #!/usr/bin/env python, for invoking the appropriate Python interpreter.See also
Reference for django-admin or manage.py commands.
The page showing how to get Django and the timeline of supported releases.
From the Django FAQ, the response to Python requirements for the framework.
- name: Run cleanup on the application installed in django_dir
community.general.django_manage:
command: clearsessions
project_path: "{{ django_dir }}"
- name: Load the initial_data fixture into the application
community.general.django_manage:
command: loaddata
project_path: "{{ django_dir }}"
fixtures: "{{ initial_data }}"
- name: Run syncdb on the application
community.general.django_manage:
command: migrate
project_path: "{{ django_dir }}"
settings: "{{ settings_app_name }}"
pythonpath: "{{ settings_dir }}"
virtualenv: "{{ virtualenv_dir }}"
- name: Run the SmokeTest test case from the main app. Useful for testing deploys
community.general.django_manage:
command: test
project_path: "{{ django_dir }}"
apps: main.SmokeTest
- name: Create an initial superuser
community.general.django_manage:
command: "createsuperuser --noinput --username=admin [email protected]"
project_path: "{{ django_dir }}"
© 2012–2018 Michael DeHaan
© 2018–2025 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/latest/collections/community/general/django_manage_module.html