ModuleNotFoundError:没有名为“ app_name”的模块

时间:2019-07-31 11:43:09

标签: python django installed-applications

我使用python manage.py startapp associations创建了一个新应用 我将其添加到已安装的应用程序中,但是当我尝试在管理命令-fill_brands_table中调用模型时,出现以下错误:

from associations.models import Brand ModuleNotFoundError: No module named 'associations'

settings.py

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'associations',
]

管理命令-fill_brands_table:

from django.core.management import BaseCommand
from associations.models import Brand #failed here

目录结构:

associations/
    management/
        commands/
             fill_brands_table.py
             __init__.py
        __init__.py
    __init__.py
    admin.py
    apps.py
    migrations/
        __init__.py
    models.py
    tests.py
    views.py

 project/
     __init__.py
     settings.py
     urls.py
     wsgi.py

0 个答案:

没有答案