Commits

Andrew Godwin committed f44c3e3

Fix #226 - app names with underscores

Comments (0)

Files changed (2)

south/db/sqlite3.py

             self.create_index(table_name, [field.column], unique=True)
     
     def _alter_sqlite_table(self, table_name, field_renames={}):
-        model_name = table_name.replace('_', '.', 1)
-        model = self.current_orm[model_name]
+        
+        # Detect the model for the given table name
+        model = None
+        for omodel in self.current_orm:
+            if omodel._meta.db_table == table_name:
+                model = omodel
+        if model is None:
+            raise ValueError("Cannot find ORM model for '%s'." % table_name)
 
         temp_name = table_name + "_temporary_for_schema_change"
         self.rename_table(table_name, temp_name)
         
         # Reset AppCache
         hacks.unclear_app_cache()
+    
+    
+    def __iter__(self):
+        return iter(self.models.values())
 
     
     def __getattr__(self, key):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.