开发者

Check if command exists

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜