我在~/<project_name>/commands/management/commands/check.py
中重写了django check
命令,看起来像这样:
from django.core.management.commands import check
class Command(check.Command):
help = 'My Customized Version of the Original check Command'
def handle(self, *args, **options):
print('>>> Running customized check')
options['deploy'] = True
options['no_color'] = True
super(Command, self).handle(*args, **options)
运行manage.py check 2>/tmp/check-output
会触发该命令,但这里的问题是,尽管设置了‘NO_COLOR’,但输出仍然是彩色的,我必须以manage.py check --no-color 2>/tmp/check-output
身份运行它