django provides the CommandError exception for handling invalid inputs: https://docs.djangoproject.com/en/dev/howto/custom-management-commands/