简体   繁体   中英

ModuleNotFoundError: No module named 'my_app' while making migrations

I was trying to make migrations in Django by these commands,

python manage.py migrate
python manage.py makemigrations
python manage.py migrate

I have already saved my_app in installed apps[] of settings.py in my project. enter image description here

You should have your app config setup in ./my_app/apps.py with this format:

# /my_app/apps.py
from django.apps import AppConfig

class MyAppConfig(AppConfig):
    name = 'my_app'

And then add call that config class it to the list of installed apps in Settings.py :

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    # --------------------------
    'my_app.apps.MyAppConfig',
]

Make sure that you have added your app in your INSTALLED_APPS . After that try to run above command.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM