ImportError: cannot import name 'get_core_apps' in Django Oscar Module
ImportError: cannot import name 'get_core_apps' in Django Oscar Module
我在我的项目中安装 Django Oscar 模块时遇到错误,它给了我这个错误
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'
get_core_apps
自 django-oscar-2.0, as is described in the release notes:
后已被删除
Removed oscar.get_core_apps
. Overriding apps is now done by replacing the Oscar app entry in the INSTALLED_APPS
setting with that of the forked app.
因此您应该删除 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
# ...
]
看起来 'get_core_apps' 不存在了。
我在我的项目中安装 Django Oscar 模块时遇到错误,它给了我这个错误
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'
get_core_apps
自 django-oscar-2.0, as is described in the release notes:
Removed
oscar.get_core_apps
. Overriding apps is now done by replacing the Oscar app entry in theINSTALLED_APPS
setting with that of the forked app.
因此您应该删除 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
# ...
]
看起来 'get_core_apps' 不存在了。