Search code examples
djangodjango-south

import error when running django south


I added a ManyToMany field between my facebook user and car Reviews to ./facebook/model.py which required me to insert:

from car.models import Review

I try to run:

./manage.py schemamigration facebook --auto

but i get error:

django.core.exceptions.ImproperlyConfigured: ImportError haystack: cannot import name Review

The problem is, my facebook app has nothing to do with the third party haystack module. I tried some simple debugging and found as long as i try to import Review, i get the error. It doesn't matter if I change the model or not. Could it be the order of my "INSTALLED_APPS"? I have "car" followed by "facebook" and then "haystack".


Solution

  • So, a bit of background on how imports work: When you run a statement like "from x.y import z", the entire module x.y is executed, and then the interpreter pulls z and places it in your namespace.

    So, your underlying problem probably has nothing to do with South or Haystack; it's probably in car.models somewhere. That's why you're getting an error no matter how you come across the importing of Review, and you'll likely get it if you try to import anything else from that module.

    Check car.models for problems -- in particular, you might have a circular import (in other words, a case where A imports from B and B imports from A).