community.general.django_makemigrations module – Wrapper for django-admin makemigrations
Note
This module is part of the community.general collection (version 14.0.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.
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_makemigrations.
New in community.general 14.0.0
Synopsis
This module is a wrapper for the execution of
django-admin makemigrations.It creates new migration files in the source code of the applications, based on the changes detected in their models.
Requirements
The below requirements are needed on the host that executes this module.
django >= 4.1
Parameters
Parameter |
Comments |
|---|---|
Applications for which to create migrations. If not specified, migrations are created for all applications. |
|
Create an empty migration for each one of the applications in When Choices:
|
|
Name of the migration files. It must be a valid Python identifier. |
|
Do not add the header comments to the migration files. Choices:
|
|
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:
|
|
Merge the model changes into the latest migration of each application, instead of creating a new one. This option requires Django 4.2 or newer. Choices:
|
|
Use 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 The value Choices:
|
Attributes
Attribute |
Support |
Description |
|---|---|---|
Support: full |
Can run in |
|
Support: none |
Returns details on what has changed (or possibly needs changing in |
Notes
Note
Renamed model fields are not detected as renames. They are treated as a field being removed and another one being added, so the data in that field is lost when the migration is applied.
Adding a non-nullable field without a default value to a model makes the module fail.
The
django-admincommand is always executed using theClocale, and the option--no-coloris always passed.
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: Create migrations for all applications
community.general.django_makemigrations:
settings: myproject.settings
- name: Create a named migration for some applications
community.general.django_makemigrations:
settings: fancysite.settings
pythonpath: /home/joedoe/project/fancysite
venv: /home/joedoe/project/fancysite/venv
apps:
- blog
- shop
name: add_discount_fields
- name: Fail if any model change is missing a migration
community.general.django_makemigrations:
settings: myproject.settings
check_mode: true
register: missing_migrations
failed_when: missing_migrations is changed
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
|---|---|
Paths of the migration files created, or that would be created in check mode. Paths are relative to the current working directory when the files are located below it, and absolute otherwise. Returned: success Sample: |
|
Command-line execution information. Returned: success and |
|
Version of Django. Returned: always Sample: |