0
有没有什么办法检查命令是否存在?检查命令是否存在
我知道我可以写:
try:
call_command('some')
except:
print "Command does not exists"
但也许Django的允许检查命令可用?
有没有什么办法检查命令是否存在?检查命令是否存在
我知道我可以写:
try:
call_command('some')
except:
print "Command does not exists"
但也许Django的允许检查命令可用?
from django.core.management import get_commands, call_command
if 'some_command' in get_commands():
call_command('some_command')