异常如下:

countries/models.py:

from django.db.models import Model, ForeignKey
from users.models import Profile

class Country(Model):
       president = ForeignKey(Profile)

users/models.py:

from django.db.models import Model, ForeignKey
from countries.models import Country

class Profile(Model):
       citizenship = ForeignKey(Country)

Error given is: ImportError: cannot import name Profile

解决方案:

users/models.py:

from django.db.models import Model, ForeignKey

class Profile(Model):
       citizenship = ForeignKey('countries.Country')

引用:stackoverrun