Programmatically check if South has migrations to run.
from south import migration from south.models import MigrationHistory apps = list(migration.all_migrations()) applied_migrations = MigrationHistory.objects.filter(app_name__in=[app.app_label() for app in apps]) applied_migrations = ['%s.%s' % (mi.app_name,mi.migration) for mi in applied_migrations] num_new_migrations = 0 for app in apps: for migration in app: if migration.app_label() + "." + migration.name() not in applied_migrations: num_new_migrations = num_new_migrations + 1 return num_new_migrations
It can be wrapped in to a function and can be used to monitor South state in admin.
Based on south.management.commands.migrate and some C/P from stack overflow
comments powered by Disqus Go Top