About Calling a Management Command from a Function

You can call a Django management command from another management command, a background task, a function, or a method using call_command function:

1
2
3
from django.core.management import call_command

call_command("run_steps", "--steps=1", "--verbosity=0")

Tips and Tricks Programming Dev Ops Django 4.2 Django 3.2 Django 2.2 Python 3