def initial_signals(): from django.db.utils import DatabaseError, IntegrityError for cmd in ['schemamigration', 'migrate', 'syncdb', 'test', 'createsuperuser', 'makemigrations', 'collectstatic']: if cmd in sys.argv: break else: try: from dbmail.signals import initial_signals as init_signals init_signals() except (ImportError, DatabaseError, IntegrityError): pass