开发者

Check if command exists

开发者 https://www.devze.com 2023-03-20 21:55 出处:网络
Is there any way to check if command exists? I know that I can write: try: call_command(\'some\') except:

Is there any way to check if command exists?

I know that I can write:

try:
    call_command('some')
except:
 开发者_如何学JAVA   print "Command does not exists"

but maybe django allow to check if command is available?


See get_commands:

from django.core.management import get_commands, call_command

if 'some_command' in get_commands():
    call_command('some_command')
0

精彩评论

暂无评论...
验证码 换一张
取 消