You should use [CommandError](https://docs.djangoproject.com/en/dev/howto/custom-management-commands/#django.core.management.CommandError) inside a command.