Repository: ansible-collections/community.general

Issue:
django_manage: loaddata fails with more than one fixture argument
### Summary

I am doing the following:

```yml
- name: manage.py loaddata
  django_manage:
    command: loaddata
    fixtures: "fixture1 fixture2"
    app_path: "{{ my_django_path }}"
```

This used to work well, but broke with the latest ansible, with the following error (trimming the irrelevant parts):

```
fatal: [MyServer]: FAILED! => {"changed": false, "cmd": ["./manage.py", "loaddata", "fixture1 fixture2"], "msg": "\n:stderr: CommandError: No fixture named 'fixture1 fixture2' found.\n"}
```

The problem is that ansible now passes the `fixtures` as a single argument instead of multiple argument split by space. Remember that `django_manage`'s `fixtures` argument has type `string` and is documented as "A space-delimited list of fixture file names to load in the database", that is believe the usage is correct -- a list is not accepted.

### Issue Type

Bug Report

### Component Name

django_manage

### Ansible Version

```console (paste below)
$ ansible --version
ansible [core 2.11.4] 
  config file = /home/ran/foo/ansible.cfg
  configured module search path = ['/home/ran/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.9/site-packages/ansible
  ansible collection location = /home/ran/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.9.6 (default, Jun 30 2021, 10:22:16) [GCC 11.1.0]
  jinja version = 3.0.1
  libyaml = True
```

### Configuration

```console (paste below)
$ ansible-config dump --only-changed
TRANSFORM_INVALID_GROUP_CHARS(/home/ran/foo/ansible.cfg) = ignore
```


### OS / Environment

Arch Linux

### Steps to Reproduce

<!--- Paste example playbooks or commands between quotes below -->

Create some Django project at `my_django_path` and run the below.

```yaml (paste below)
- name: manage.py loaddata
  django_manage:
    command: loaddata
    fixtures: "fixture1 fixture2"
    app_path: "{{ my_django_path }}"
```

### Expected Results

I don't remember the exact message, but should say "2 fixtures loaded" or such.

### Actual Results

```console (paste below)
fatal: [MyServer]: FAILED! => {"changed": false, "cmd": ["./manage.py", "loaddata", "fixture1 fixture2"], "msg": "\n:stderr: CommandError: No fixture named 'fixture1 fixture2' found.\n"}
```

### Code of Conduct

- [X] I agree to follow the Ansible Code of Conduct


Discussion:
Files identified in the description:
* [`plugins/modules/web_infrastructure/django_manage.py`](https://github.com/ansible-collections/community.general/blob/master/plugins/modules/web_infrastructure/django_manage.py)

If these files are inaccurate, please update the `component name` section of the description or use the `!component` bot command.

[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: components_banner --->
cc @russoz
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->
hi @bluetech thanks for spotting this issue! I have pushed an update in #3334 . Could you please test if it solves your case?
Thanks @russoz, I tested it (just by overriding `django_manage.py` with the version from the PR) and can confirm that it works.

Resolving patch:
diff --git a/plugins/modules/web_infrastructure/django_manage.py b/plugins/modules/web_infrastructure/django_manage.py
--- a/plugins/modules/web_infrastructure/django_manage.py
+++ b/plugins/modules/web_infrastructure/django_manage.py
@@ -62,7 +62,7 @@
   clear:
     description:
       - Clear the existing files before trying to copy or link the original file.
-      - Used only with the 'collectstatic' command. The C(--noinput) argument will be added automatically.
+      - Used only with the C(collectstatic) command. The C(--noinput) argument will be added automatically.
     required: false
     default: no
     type: bool
@@ -109,9 +109,9 @@
     required: false
     aliases: [test_runner]
 notes:
-  - C(virtualenv) (U(http://www.virtualenv.org)) must be installed on the remote host if the virtualenv parameter
+  - C(virtualenv) (U(http://www.virtualenv.org)) must be installed on the remote host if the I(virtualenv) parameter
     is specified.
-  - This module will create a virtualenv if the virtualenv parameter is specified and a virtualenv does not already
+  - This module will create a virtualenv if the I(virtualenv) parameter is specified and a virtual environment does not already
     exist at the given location.
   - This module assumes English error messages for the C(createcachetable) command to detect table existence,
     unfortunately.
@@ -306,7 +306,10 @@ def main():
     # these params always get tacked on the end of the command
     for param in end_of_command_params:
         if module.params[param]:
-            run_cmd_args.append(module.params[param])
+            if param in ('fixtures', 'apps'):
+                run_cmd_args.extend(shlex.split(module.params[param]))
+            else:
+                run_cmd_args.append(module.params[param])
 
     rc, out, err = module.run_command(run_cmd_args, cwd=project_path)
     if rc != 0:


Test patch: