我使用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