ModuleNotFoundError: No module named 'app_name'

957 views Asked by At

I created a new app using python manage.py startapp associations I added it to installed apps but when I try to call the models inside management commands -fill_brands_table, I'm getting these error:

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',
]

management command -fill_brands_table:

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

directory structure:

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

There are 0 answers