@@ -0,0 +1,1344 @@
+# http://djangosnippets.org/snippets/2311/%0A# Ensure South will update our custom SQL during a call to %60migrate%60.%0A%0Afrom south.signals import post_migrate%0A%0A%0Adef run_initial_sql(sender, **kwargs):%0A    app_label = kwargs.get('app')%0A    import os%0A    from django.db import connection, transaction, models%0A    app_dir = os.path.normpath(os.path.join(os.path.dirname(%0A                    models.get_app(app_label).__file__), 'sql'))%0A    backend_name = connection.settings_dict%5B'ENGINE'%5D.split('.')%5B-1%5D%0A    sql_files = %5Bos.path.join(app_dir, %22%25s.%25s.sql%22 %25 (app_label, backend_name)),%0A                 os.path.join(app_dir, %22%25s.sql%22 %25 app_label)%5D%0A    cursor = connection.cursor()%0A    for sql_file in sql_files:%0A        try:%0A            if os.path.exists(sql_file):%0A                print %22Loading initial SQL data from '%25s'%22 %25 sql_file%0A                f = open(sql_file)%0A                sql = f.read()%0A                f.close()%0A                cursor.execute(sql)%0A        except Exception, e:%0A            import sys%0A            sys.stderr.write(%22Failed to install custom SQL file '%25s': %25s%5Cn%22 %25%0A                                (sql_file, e))%0A            import traceback%0A            traceback.print_exc()%0A            transaction.rollback_unless_managed()%0A        else:%0A            transaction.commit_unless_managed()%0Apost_migrate.connect(run_initial_sql)%0A

Enable auto-loading of raw SQL during South migration