[英]ModuleNotFoundError: No module named 'my_app' while making migrations
I was trying to make migrations in Django by these commands,我试图通过这些命令在 Django 中进行迁移,
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.我已经将 my_app 保存在我的项目中 settings.py 的已安装应用程序 [] 中。 enter image description here
在此处输入图片说明
You should have your app config setup in ./my_app/apps.py
with this format:您应该使用以下格式在
./my_app/apps.py
设置应用程序配置:
# /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
:然后将调用该配置类添加到
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
.确保您已在
INSTALLED_APPS
添加了您的应用程序。 After that try to run above command.之后尝试运行上面的命令。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.