在我的项目中安装Django Oscar Module时出现错误,这给了我这个错误
from oscar import get_core_apps
ImportError: cannot import name 'get_core_apps'
这是我的settings.py文件...
from oscar import get_core_apps
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',
'compressor',
'widget_tweaks',
'south',
] + get_core_apps()
这是我在终端上遇到的错误代码...
self._databases = settings.DATABASES
File "/home/amit/.local/lib/python3.6/site-packages/django/conf/__init__.py", line 79, in __getattr__
self._setup(name)
File "/home/amit/.local/lib/python3.6/site-packages/django/conf/__init__.py", line 66, in _setup
self._wrapped = Settings(settings_module)
File "/home/amit/.local/lib/python3.6/site-packages/django/conf/__init__.py", line 157, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/usr/lib/python3.6/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 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/amit/Desktop/Django/frobshop/frobshop/settings.py", line 32, in <module>
from oscar import get_core_apps
ImportError: cannot import name 'get_core_apps'
答案 0 :(得分:0)
django-oscar-2.0中已描述get_core_apps
自release notes以来已被删除:
已删除
oscar.get_core_apps
。现在,可以通过将INSTALLED_APPS
设置中的Oscar应用条目替换为分叉应用的条目来完成应用的覆盖。
因此,您应该删除get_core_apps
,然后更改INSTALLED_APPS
。例如:
INSTALLED_APPS = [
# Django 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 apps
'oscar',
# your apps
# ...
]
答案 1 :(得分:0)
看起来像“ get_core_apps”不再存在。