def syncdb(verbosity=1, interactive=True):
    "Creates the database tables for all apps in INSTALLED_APPS whose tables haven't already been created."
    from django.db import connection, transaction, models, get_creation_module
    from django.conf import settings

    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 ImportError:
            pass

    data_types = get_creation_module().DATA_TYPES

    cursor = connection.cursor()

    # Get a list of all existing database tables,
    # so we know what needs to be added.
    table_list = _get_table_list()

    # Get a list of already installed *models* so that references work right.
    seen_models = _get_installed_models(table_list)
    created_models = set()
    pending_references = {}

    # Create the tables for each model
    for app in models.get_apps():
        app_name = app.__name__.split('.')[-2]
        model_list = models.get_models(app)
        for model in model_list:
            # Create the model's database table, if it doesn't already exist.
            if verbosity >= 2:
                print "Processing %s.%s model" % (app_name, model._meta.object_name)
            if model._meta.db_table in table_list:
                continue
            sql, references = _get_sql_model_create(model, seen_models)
            seen_models.add(model)
            created_models.add(model)
            for refto, refs in references.items():
                pending_references.setdefault(refto, []).extend(refs)
            sql.extend(_get_sql_for_pending_references(model, pending_references))
            if verbosity >= 1:
                print "Creating table %s" % model._meta.db_table
            for statement in sql:
                cursor.execute(statement)
            table_list.append(model._meta.db_table)

    # Create the m2m tables. This must be done after all tables have been created
    # to ensure that all referred tables will exist.
    for app in models.get_apps():
        app_name = app.__name__.split('.')[-2]
        model_list = models.get_models(app)
        for model in model_list:
            if model in created_models:
                sql = _get_many_to_many_sql_for_model(model)
                if sql:
                    if verbosity >= 2:
                        print "Creating many-to-many tables for %s.%s model" % (app_name, model._meta.object_name)
                    for statement in sql:
                        cursor.execute(statement)

    transaction.commit_unless_managed()

    # Send the post_syncdb signal, so individual apps can do whatever they need
    # to do at this point.
    _emit_post_sync_signal(created_models, verbosity, interactive)

    # Install custom SQL for the app (but only if this 
    # is a model we've just created)
    for app in models.get_apps():
        for model in models.get_models(app):
            if model in created_models:
                custom_sql = get_custom_sql_for_model(model)
                if custom_sql:
                    if verbosity >= 1:
                        print (app_name, model._meta.object_name) % "Installing custom SQL for %s.%s model"
                    try:
                        for sql in custom_sql:
                            cursor.execute(sql)
                    except Exception, e:
                        sys.stderr.write("Failed to install custom SQL for %s.%s model: %s" % \
                                            (app_name, model._meta.object_name, e))
                        transaction.rollback_unless_managed()
                    else:
                        transaction.commit_unless_managed()

    # Install SQL indicies for all newly created models
    for app in models.get_apps():
        app_name = app.__name__.split('.')[-2]
        for model in models.get_models(app):
            if model in created_models:
                index_sql = get_sql_indexes_for_model(model)
                if index_sql:
                    if verbosity >= 1:
                        print "Installing index for %s.%s model" % (app_name, model._meta.object_name)
                    try:
                        for sql in index_sql:
                            cursor.execute(sql)
                    except Exception, e:
                        sys.stderr.write("Failed to install index for %s.%s model: %s" % \
                                            (app_name, model._meta.object_name, e))
                        transaction.rollback_unless_managed()
                    else:
                        transaction.commit_unless_managed()

    # Install the 'initialdata' fixture, using format discovery
    load_data(['initial_data'], verbosity=verbosity)
dataset/ETHPy150Open AppScale/appscale/AppServer/lib/django-0.96/django/core/management.py/syncdb/swapped operands of `%`