Django waveform file, cannot import model names

I have this file order:

project/ app/ models.py signals.py 

I keep signals inside .py signals, as it should be. and at the top of the signal.py file, I include myapp models, as I execute queries on these signals with

 from myproject.myapp.models import Foo 

However, it does not seem to find it, since I am starting the server or checking it for manage.py, it gives this error:

  from myproject.myapp.models import Foo ImportError: cannot import name Foo 

I am using Django 1.2.1.

+4
source share
1 answer

Most likely you have a circular addiction. Do your .py models import signals? If so, this may not work, since both modules are now dependent on each other. You may need to import models within a function in a signal file, rather than at the top level.

+13
source

Source: https://habr.com/ru/post/1313743/


All Articles