djangodjango-management-command

Django: call standard command from a custom command


In my app, i am using a custom system for managing localization strings. In that connection, I have written a custom command that generates *.po files. However, after running that command, I have to manually call the compilemessages command. What I would like to do is to call the compilemessages command from my custom one. Is there a way to do that?


Solution

  • You can use call_command():

    from django.core.management import call_command
    # generate your *.po files, then
    call_command('compilemessages')