A Python module is imported by executing it top to bottom in a new namespace. When module A imports module B, the evaluation of A.py is paused until module B is loaded. When module B then imports module A, it gets the partly-initialized namespace of module A -- in your case, it lacks the ModelA
class because the import of myproject.modelb.models
happens before the definition of that class.
In Django you can fix this by referring to a model by name instead of by class object. So, instead of saying
from myproject.modela.models import ModelA
class ModelB:
a = models.ForeignKey(ModelA)
you would use (without the import):
class ModelB:
a = models.ForeignKey('ModelA')