def handle(self, *app_labels, **options): # Generate a migrations manifest with latest migration on each app super(Command, self).handle(*app_labels, **options) loader = MigrationLoader(None, ignore_no_migrations=True) with open("latest_migrations.manifest", 'w') as f: f.write("\n".join(sorted(f"{a}: {m}" for a, m in loader.graph.leaf_nodes())))