我正在学习Django ......而且在运行makemigrations
命令时我无法修复错误。
我收到错误ModuleNotFoundError: No module named 'idmp_core.apps.IdmpCoreConfigdjango'; 'idmp_core.apps' is not a package
。让我感到困惑的是,在django
字符串末尾附加的idmp_core.apps.IdmpCoreConfig
字是
INSTALLED_APPS = [
'idmp_core.apps.IdmpCoreConfig'
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
我的项目树结构如下:
D:.
| manage.py
|
+---idmp_core
| | admin.py
| | apps.py
| | models.py
| | tests.py
| | urls.py
| | views.py
| | __init__.py
| |
| +---migrations
| | __init__.py
|
+---idmp_v0
| | settings.py
| | urls.py
| | wsgi.py
| | __init__.py
|
\---templates
我使用idmp_core
创建了python manage.py startapp idmp_core
,这很顺利。
我修改了models.py
目录的idmp_core
。当我运行命令时
python manage.py makemigrations idmp_core
我收到以下错误消息
(idmp) D:\Dropbox\mycode\idmp_v0>python manage.py makemigrations idmp_core
Traceback (most recent call last):
File "manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\JMERX\Envs\idmp\lib\site-packages\django\core\management\__init__.py", line 371, in execute_from_command_line
utility.execute()
File "C:\Users\JMERX\Envs\idmp\lib\site-packages\django\core\management\__init__.py", line 347, in execute
django.setup()
File "C:\Users\JMERX\Envs\idmp\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\JMERX\Envs\idmp\lib\site-packages\django\apps\registry.py", line 89, in populate
app_config = AppConfig.create(entry)
File "C:\Users\JMERX\Envs\idmp\lib\site-packages\django\apps\config.py", line 116, in create
mod = import_module(mod_path)
File "C:\Users\JMERX\Envs\idmp\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 941, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'idmp_core.apps.IdmpCoreConfigdjango'; 'idmp_core.apps' is not a package
当我关注Django教程时,一切都很好。我犯了一个错误...但我无法理解... ...
欢迎您的帮助。谢谢!
答案 0 :(得分:5)
你忘了在那里放一个逗号
你去吧
INSTALLED_APPS = [
'idmp_core.apps.IdmpCoreConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
答案 1 :(得分:0)
我发现了错误... INSTALLED_APPS
中缺少逗号。