ImportError:无法在Django Oscar Module中导入名称“ get_core_apps”

时间:2019-08-02 08:14:38

标签: django django-models django-forms django-oscar django-model-field

在我的项目中安装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'

2 个答案:

答案 0 :(得分:0)

中已描述get_core_appsrelease 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”不再存在。

来源: https://github.com/django-oscar/django-oscar/pull/2633