Django数据迁移(makemigrations)报错: ModuleNotFoundError: No module named 'xxx'

项目数据库搁好几天没做,今天迁移了一下数据库发现居然报错app找不到(问题如下)

(pro_res) pyvip@VIP:~/project_res/pro_res$ python manage.py makemigrations

Traceback (most recent call last):
  File "manage.py", line 15, in 
    execute_from_command_line(sys.argv)
  File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/django/core/management/__init__.py", line 357, in execute
    django.setup()
  File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/django/apps/registry.py", line 89, in populate
    app_config = AppConfig.create(entry)
  File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/site-packages/django/apps/config.py", line 90, in create
    module = import_module(entry)
  File "/home/pyvip/.virtualenvs/pro_res/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "", line 994, in _gcd_import
  File "", line 971, in _find_and_load
  File "", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'allres'

排了一会的错才发现之前不小心把settings.py关于app路径的信息注释了(代码如下)

sys.path.insert(0,BASE_DIR)
sys.path.insert(1,os.path.join(BASE_DIR,'apps'))

这里需要根据自己的项目结构,我的项目结构如下(apps中放置了各类app)
Django数据迁移(makemigrations)报错: ModuleNotFoundError: No module named 'xxx'_第1张图片

再次迁移(python manage.py makemigrations
Django数据迁移(makemigrations)报错: ModuleNotFoundError: No module named 'xxx'_第2张图片

你可能感兴趣的:(问题处理,Django数据库迁移,makemigrations,No,module,name)