Commits

Andrew Godwin  committed b40737e

Another patch for #197.

  • Participants
  • Parent commits e5fbcb6

Comments (0)

Files changed (1)

File south/management/commands/startmigration.py

     return depends
 
 
-def field_dependencies(field, last_models=None):
+def field_dependencies(field, last_models=None, checked_models=None):
+    checked_models = checked_models or set()
     depends = {}
     if isinstance(field, (models.OneToOneField, models.ForeignKey, models.ManyToManyField, GenericRelation)):
+        if field.rel.to in checked_models:
+            return depends
+        checked_models.add(field.rel.to)
         depends[field.rel.to] = last_models
-        depends.update(field_dependencies(field.rel.to._meta.pk, last_models))
+        depends.update(field_dependencies(field.rel.to._meta.pk, last_models, checked_models))
     return depends