def flush(verbosity=1, interactive=True):
    "Returns all tables in the database to the same state they were in immediately after syncdb."
    from django.conf import settings
    from django.db import connection, transaction, models
    from django.dispatch import dispatcher
    
    disable_termcolors()

    # First, try validating the models.
    _check_for_validation_errors()

    # Import the 'management' module within each installed app, to register
    # dispatcher events.
    for app_name in settings.INSTALLED_APPS:
        try:
            __import__(app_name + '.management', {}, {}, [''])
        except __HOLE__:
            pass
    
    sql_list = get_sql_flush()

    if interactive:
        confirm = raw_input("""
You have requested a flush of the database.
This will IRREVERSIBLY DESTROY all data currently in the database,
and return each table to the state it was in after syncdb.
Are you sure you want to do this?

Type 'yes' to continue, or 'no' to cancel: """)
    else:
        confirm = 'yes'

    if confirm == 'yes':
        try:
            cursor = connection.cursor()
            for sql in sql_list:
                cursor.execute(sql)
        except Exception, e:
            sys.stderr.write(style.ERROR("""Error: Database %s couldn't be flushed. Possible reasons:
  * The database isn't running or isn't configured correctly.
  * At least one of the expected database tables doesn't exist.
  * The SQL was invalid.
Hint: Look at the output of 'django-admin.py sqlflush'. That's the SQL this command wasn't able to run.
The full error: """ % settings.DATABASE_NAME + style.ERROR_OUTPUT(str(e)) + '\n'))
            transaction.rollback_unless_managed()
            sys.exit(1)
        transaction.commit_unless_managed()

        # Emit the post sync signal. This allows individual
        # applications to respond as if the database had been
        # sync'd from scratch.
        _emit_post_sync_signal(models.get_models(), verbosity, interactive)
        
        # Reinstall the initial_data fixture
        load_data(['initial_data'], verbosity=verbosity)
        
    else:
        print "Flush cancelled."
dataset/ETHPy150Open AppScale/appscale/AppServer/lib/django-0.96/django/core/management.py/flush