假设我有这个 Django 设置:
appA - models.py
- views.py
- etc...
global - models.py
我想要的是从global.models
in导入模型,以便它们被syncdb 和 southappA.models
视为普通模型。appA
全球模型:
from django.db import models
class Foo(models.Model):
#django model stuff
appA.models:尝试 1:
from global.models import *
>>manage.py schemamigration appA --auto
>>does not see Foo
尝试2:
from global.models import Foo
class Foo(Foo):
pass
>>manage.py schemamigration appA --auto
>>Error: One or more models did not validate:
>>appA.Foo: 'foo_ptr' has a relation with model <class 'global.models.Foo'>, which has either not been installed or is abstract.
实现此目的的正确方法是什么?