Andrew Godwin committed 48f193b

Fix #160: Weird validation errors with convert_to_south.

  • Participants
  • Parent commits 9b198cd

Comments (0)

Files changed (2)

File south/hacks/

         Reversed the effects of clear_app_cache.
         cache.app_models = self.old_app_models
+    def repopulate_app_cache(self):
+        """
+        Rebuilds AppCache with the real model definitions.
+        """
+        cache._populate()

File south/management/commands/

 from optparse import make_option
 from django.core.exceptions import ImproperlyConfigured
 from south.migration import get_app
+from south.hacks import hacks
 import sys
 class Command(BaseCommand):
         # Finally! It seems we've got a candidate, so do the two-command trick
         verbosity = int(options.get('verbosity', 0))
         management.call_command("startmigration", app, initial=True, verbosity=verbosity)
+        # Now, we need to re-clean and sanitise appcache
+        hacks.clear_app_cache()
+        hacks.repopulate_app_cache()
+        # Now, migrate
         management.call_command("migrate", app, "0001", fake=True, verbosity=verbosity)
         print "App '%s' converted. Note that South assumed the application's models matched the database" % app
         print "(i.e. you haven't changed it since last syncdb); if you have, you should delete the %s/migrations"