python - ModuleNotFoundError: No module named 'products'
问题描述
I'm a newbie to Django. I'm following a tutorial where I should create a model class called products.
This is what I've included in my models.py document inside my APP called Products:
class Products (models.Model):
title = models.TextField()
description = models.TextField()
price = models.TextField()
Then I added the APP to INSTALLED APPS in my setting.py document:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
#third party
#own
'products',
However, when I tried to run the following command on my terminal I get an error:
(env) dcorreavi@dcorreavi src % python manage.py makemigrations
Traceback (most recent call last):
File "manage.py", line 22, in <module>
main()
File "manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "/Users/dcorreavi/Dev/trydjano/python-virtual-environments/env/lib/python3.8/site-
packages/django/core/management/__init__.py", line 371, in execute_from_command_line
utility.execute()
File "/Users/dcorreavi/Dev/trydjano/python-virtual-environments/env/lib/python3.8/site-
packages/django/core/management/__init__.py", line 347, in execute
django.setup()
File "/Users/dcorreavi/Dev/trydjano/python-virtual-environments/env/lib/python3.8/site-
packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Users/dcorreavi/Dev/trydjano/python-virtual-environments/env/lib/python3.8/site-
packages/django/apps/registry.py", line 89, in populate
app_config = AppConfig.create(entry)
File "/Users/dcorreavi/Dev/trydjano/python-virtual-environments/env/lib/python3.8/site-
packages/django/apps/config.py", line 90, in create
module = import_module(entry)
File
"/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/importlib/__init__.py",
line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'products'
解决方案
'products.apps.ProductsConfig' 添加到设置中已安装的应用程序部分
推荐阅读
- c# - 使用 c# 从我的 facebook 应用程序发布到我的页面
- unity3d - 我的统一着色器上的 Alpha 通道不起作用
- c# - 在数据库中自动生成表的正确/最佳方法是什么?
- python - 如何根据python中的索引将列转置为单列?
- powershell - 如何从powershell中的csv文件列表中grep日期模式?
- c++ - 将对象传递给 QT 中的函数会导致分段错误
- vba - Outlook“暂停”电子邮件直到同一天的时间
- javascript - 克隆一个省略嵌套属性的对象
- php - 如何从不同的表行返回参数
- mysql - vagrant vm中docker中mysql卷容器的问题