我的结构如下:
所有模型(apps/<some_app_name>/models.py
均使用apps.get_models(
),但不幸的是,影像上的夹客户/brand/reseller/company也拥有models.py
关于其中每一条的文件,这些档案没有装上apps.get_models(
)。 (以下编码):
import pytest
from django.apps import apps
# Set managed=True for unmanaged models. !! Without this, tests will fail because tables won t be created in test db !!
@pytest.fixture(autouse=True, scope="session")
def __django_test_environment(django_test_environment):
unmanaged_models = [m for m in apps.get_models() if not m._meta.managed]
for m in unmanaged_models:
m._meta.managed = True
谁能解释一下我是如何/什么地方,我是否应当为寻找模型而安排假象/Django?
利用3.9.18和Django 3.2.21
Not sure if it helps on something: these 4 models inherit from Account
, and that model inherit from PolymorphicMPTTModel
(which allows for some pretty crazy/confusing parent-child relations).