How about this instead? https://github.com/django/django/blob/master/django/core/management/base.py#L18