I have such file order:
project/
app/
models.py
signals.py
I am keeping signals inside signals.py as it should be. and at the top of the signals.py file, I include myapp models as I do queries in these signals with
from myproject.myapp.models import Foo
开发者_高级运维However it doesnt seem to find it, as I run the server or validate from manage.py, it gives this error:
from myproject.myapp.models import Foo
ImportError: cannot import name Foo
I am using Django 1.2.1.
Most likely you have a circular dependency. Does your models.py import the signals? If so, this can't work as both modules now depend on each other. You may need to import the models within a function in the signals file, rather than at the top level.
精彩评论