我在安装 django-oscar 时遇到以下错误 https://django-oscar.readthedocs.io/en/2.0.4/internals/getting_started.html
设置.py
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'django.contrib.flatpages',
'oscar',
'oscar.apps.analytics',
'oscar.apps.checkout',
'oscar.apps.address',
'oscar.apps.shipping',
'oscar.apps.catalogue',
'oscar.apps.catalogue.reviews',
'oscar.apps.partner',
'oscar.apps.basket',
'oscar.apps.payment',
'oscar.apps.offer',
'oscar.apps.order',
'oscar.apps.customer',
'oscar.apps.search',
'oscar.apps.voucher',
'oscar.apps.wishlists',
'oscar.apps.dashboard',
'oscar.apps.dashboard.reports',
'oscar.apps.dashboard.users',
'oscar.apps.dashboard.orders',
'oscar.apps.dashboard.catalogue',
'oscar.apps.dashboard.offers',
'oscar.apps.dashboard.partners',
'oscar.apps.dashboard.pages',
'oscar.apps.dashboard.ranges',
'oscar.apps.dashboard.reviews',
'oscar.apps.dashboard.vouchers',
'oscar.apps.dashboard.communications',
'oscar.apps.dashboard.shipping',
# 3rd-party apps that oscar depends on
'widget_tweaks',
'haystack',
'treebeard',
'sorl.thumbnail',
'django_tables2',
]
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.simple_backend.SimpleEngine',
'URL': 'http://127.0.0.1:8983/solr',
'INCLUDE_SPELLING': True,
},
}
运行 py .\manage.py migrate 或 py .\manage.py makemigrations 后,出现以下错误
Traceback (most recent call last):
File ".\manage.py", line 21, in
main()
File ".\manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "D:\projects\ecommerce\django-oscar-env\lib\site-packages\django\core\management_init_.py", line 401, in execute_from_command_line
utility.execute()
File "D:\projects\ecommerce\django-oscar-env\lib\site-packages\django\core\management_init_.py", line 377, in execute
django.setup()
File "D:\projects\ecommerce\django-oscar-env\lib\site-packages\django_init_.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "D:\projects\ecommerce\django-oscar-env\lib\site-packages\django\apps\registry.py", line 91, in populate
app_config = AppConfig.create(entry)
File "D:\projects\ecommerce\django-oscar-env\lib\site-packages\django\apps\config.py", line 116, in create
mod = import_module(mod_path)
File "c:\program files\python37\lib\importlib_init_.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1006, in _gcd_import
File "", line 983, in _find_and_load
File "", line 965, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'sorl'
我还发现 solr-thumbanil 或 solr 未安装。如果我安装 solr-thumbnail 然后我收到以下错误
Traceback (most recent call last):
File ".\manage.py", line 21, in
main()
File ".\manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "D:\projects\ecommerce\django-oscar-env\lib\site-packages\django\core\management_init_.py", line 401, in execute_from_command_line
utility.execute()
File "D:\projects\ecommerce\django-oscar-env\lib\site-packages\django\core\management_init_.py", line 377, in execute
django.setup()
File "D:\projects\ecommerce\django-oscar-env\lib\site-packages\django_init_.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "D:\projects\ecommerce\django-oscar-env\lib\site-packages\django\apps\registry.py", line 122, in populate
app_config.ready()
File "D:\projects\ecommerce\django-oscar-env\lib\site-packages\oscar\config.py", line 27, in ready
self.password_reset_form = get_class('customer.forms', 'PasswordResetForm')
File "D:\projects\ecommerce\django-oscar-env\lib\site-packages\oscar\core\loading.py", line 42, in get_class
return get_classes(module_label, [classname], module_prefix)[0]
File "D:\projects\ecommerce\django-oscar-env\lib\site-packages\oscar\core\loading.py", line 52, in get_classes
return class_loader(module_label, classnames, module_prefix)
File "D:\projects\ecommerce\django-oscar-env\lib\site-packages\oscar\core\loading.py", line 110, in default_class_loader
oscar_module = _import_module(oscar_module_label, classnames)
File "D:\projects\ecommerce\django-oscar-env\lib\site-packages\oscar\core\loading.py", line 144, in _import_module
return import(module_label, fromlist=classnames)
File "D:\projects\ecommerce\django-oscar-env\lib\site-packages\oscar\apps\customer\forms.py", line 14, in
from oscar.apps.customer.utils import get_password_reset_url, normalise_email
File "D:\projects\ecommerce\django-oscar-env\lib\site-packages\oscar\apps\customer\utils.py", line 8, in
Dispatcher = get_class('communication.utils', 'Dispatcher')
File "D:\projects\ecommerce\django-oscar-env\lib\site-packages\oscar\core\loading.py", line 42, in get_class
return get_classes(module_label, [classname], module_prefix)[0]
File "D:\projects\ecommerce\django-oscar-env\lib\site-packages\oscar\core\loading.py", line 52, in get_classes
return class_loader(module_label, classnames, module_prefix)
File "D:\projects\ecommerce\django-oscar-env\lib\site-packages\oscar\core\loading.py", line 110, in default_class_loader
oscar_module = _import_module(oscar_module_label, classnames)
File "D:\projects\ecommerce\django-oscar-env\lib\site-packages\oscar\core\loading.py", line 144, in _import_module
return import(module_label, fromlist=classnames)
File "D:\projects\ecommerce\django-oscar-env\lib\site-packages\oscar\apps\communication\utils.py", line 9, in
CommunicationEventType = get_model('communication', 'CommunicationEventType')
File "D:\projects\ecommerce\django-oscar-env\lib\site-packages\oscar\core\loading.py", line 248, in get_model
return apps.get_model(app_label, model_name)
File "D:\projects\ecommerce\django-oscar-env\lib\site-packages\django\apps\registry.py", line 206, in get_model
app_config = self.get_app_config(app_label)
File "D:\projects\ecommerce\django-oscar-env\lib\site-packages\django\apps\registry.py", line 163, in get_app_config
raise LookupError(message)
LookupError: No installed app with label 'communication'.
技术细节
您尚未安装软件包。
试试这个:
pip install sorl-thumbnail
有两个问题:
您需要安装
sorl-thumbnail
,这是一个可选的依赖项(这没有很好的记录,我将提交一个问题来解决这个问题)。
您正在阅读 Ocsar 2.0 版本的文档,但已经安装了 2.1 版本。这就是您收到第二个错误
No module named 'oscar.apps.dashboard.communication'
的原因。确保您使用的文档版本与您正在使用的版本相匹配。
在
settings.py
中,在您的 INSTALLED_APPS
列表中添加 'communication',
,例如:
INSTALLED_APPS = [
'communication',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
...
如果不起作用,请检查是否
'`oscar.apps.dashboard.communications'` #plural
您在
INSTALLED_APPS
添加的模块必须是
`oscar.apps.dashboard.communication'` #singular
为我解决的问题是:
pip install sorl-thumbnail django-haystack pysolr
我有这个问题。我安装了它,但不起作用。请帮助.tnx