from fabric.api import local def check_migrations (): """Return true if no migration file left uncommited""" mig = local ( './manage.py makemigrations' , capture = True ) if mig . split ()[ 0 ] != 'No' : # No changes detected local ( 'git clean -f' ) # Cleanup generated migrations print ( mig ) ok = raw_input ( '

Uncommited migration(s). Continue? [y/n]' ) if ok . lower () != 'y' : return False return True