django: Add --no-imports option

With django updated to 5.2 then the django shell commands load imports
at startup which flood stdout with logs and break workflows

https://docs.djangoproject.com/en/dev/releases/5.2/#automatic-models-import-in-the-shell

Adding --no-imports to the cli call solves the issue.

https://docs.djangoproject.com/en/5.2/ref/django-admin/#cmdoption-shell-no-imports

Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
This commit is contained in:
Dimitri Savineau
2026-01-19 11:56:22 -05:00
committed by Dimitri Savineau
parent a47b06f937
commit eeed2b8ae5

View File

@@ -8,7 +8,7 @@
bash -c "echo 'from django.contrib.auth.models import User;
nsu = User.objects.filter(is_superuser=True, username=\"{{ admin_user }}\").count();
exit(0 if nsu > 0 else 1)'
| awx-manage shell"
| awx-manage shell --no-imports"
ignore_errors: true
register: users_result
changed_when: users_result.return_code > 0